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