c控制语句:分支和跳转2

a、编写一个程序读取输入,读到#字符停止,然后报告读取的空格数、换行符数和所有其他字符的数量。


#include<stdio.h>
int main()
{
    int space=0,line=0,other=0;
    char ch;
    while((ch=getchar())!='#')
    {
        if(ch==' ')
            space++;
        else if(ch=='\n')
            line++;
        else
            other++;
    }
    printf("%d\t%d\t%d\n",space,line,other);

    return 0;
}