输出很多笑脸
enter a char: cEnter col, row: 5 9
程序代码:
# include <stdio.h> void chline (char, int, int); int main (void) { int col, row; char ch; printf ("enter a char: "); while ( ch = getchar() != '#') { if (ch == '\n') continue; printf ("Enter col, row: "); if (scanf ("%d%d", &col, &row) != 2) break; chline (ch, col, row); } return 0; } void chline (char ch, int n1, int n2) { int col, row; for (col=0; col<n1; ++col) { for (row=0; row<n2; ++row) printf ("%c", ch); printf ("\n"); } }
输出很多笑脸,为什么会这样?