编辑代码

#include <stdio.h>
//打印一个字符 几行几列

void display(char cr,int lines,int width);

int main (void) 
{
    int ch;         //待打印字符
    int rows,cols;

    printf("请输入一字符和2数字:\n");
    while ((ch=getchar()) != '\n')
    {
        if (scanf("%d %d",&rows,&cols) != 2)
            break;
        // scanf("%d %d",&rows,&cols);
        display(ch,rows,cols);
        while (getchar() != '\n')
            continue;
       printf("请输入其他xx \n");
       printf("回车退出\n");
    }
	printf("bye \n");
	return 0;
}

void display(char cr,int lines,int width)
{
    int row,col;
    for (row=1;row <= lines;row++)
    {
        for (col = 1;col <= width;col++)
            putchar(cr);
        putchar('\n');
    }
}