请问是需要两个程序还是一个程序实现两个功能呢?以下是分别实现两个功能的程序:

  1. 输入两个数字,打印出几行几列的“*”
#include <stdio.h>

int main() {
    int rows, cols;
    printf("请输入行数和列数:");
    scanf("%d %d", &rows, &cols);
    int i = 0, j = 0;
    while (i < rows) {
        j = 0;
        while (j < cols) {
            printf("*");
            j++;
        }
        printf("\n");
        i++;
    }
    return 0;
}
  1. 分别输入两个数字,打印出几行几列的“*”
#include <stdio.h>

int main() {
    int rows, cols;
    printf("请输入第一个数字:");
    scanf("%d", &rows);
    printf("请输入第二个数字:");
    scanf("%d", &cols);
    int i = 0, j = 0;
    while (i < rows) {
        j = 0;
        while (j < cols) {
            printf("*");
            j++;
        }
        printf("\n");
        i++;
    }
    return 0;
}
用c语言的while语句实现以下效果输入两个数字打印出几行几列的请求失败2用c语言的while语句实现以下效果分别输入两个数字打印出几行几列的

原文地址: https://www.cveoy.top/t/topic/bU5P 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录