输入一行字符,分别统计出其中空格的个数。用C语言编程,不能用数组

如题所述

//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
    int n=0,ch;
    while((ch=getchar())!='\n')
        if(ch==' ')
            n++;
    printf("In this lin, a total of %d Spaces.\n",n);
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜