在行和列中打印字符

#include <stdio.h>
void display(char cr, int lines, int width);

int main(void)
{
    int ch;             
    int rows, cols;     /* number of rows and columns   */
    printf(Enter a character and two integers:\n);
    while ((ch = getchar()) != '\n')
    {
        if (scanf(%d %d,&rows, &cols) != 2)
            break;
        display(ch, rows, cols);
        while (getchar() !=  '\n')
            continue;
        printf(Enter another character and two integers;\n);
        printf(Enter a newline to quit.\n);
    }
    printf(from jb51.cc. com.\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');  /* end line and start a new one */
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。