c语言 8-9
1、
#include <stdio.h> int main(void) { int ch; int rows = 0; while((ch = getchar()) != EOF) { switch(ch) { case '\n': rows++; break; } } printf("number of rows: %d\n", rows); return 0; }

2、
#include <stdio.h> int main(void) { int ch; int rows = 0; while((ch = getchar()) != EOF) { if(ch == '\n') rows++; } printf("number of rows: %d\n", rows); return 0; }

3、
#include <stdio.h> int main(void) { int ch; int rows = 0; while( ch = getchar()) { if(ch == EOF) break; if(ch == '\n') rows++; } printf("number of rows: %d\n", rows); return 0; }


浙公网安备 33010602011771号