lind6-2.c

来自「谭浩强第二版的课后习题的答案的源程序」· C语言 代码 · 共 29 行

C
29
字号
#include<stdio.h>
void main()
{
	char str;
	int words=0,space=0,number=0,others=0;
	while((str=getchar())!='\n')
	{
		if(str==32)
		{
			space++;
		}
		else if(((str>=65)&&(str<=90))||((str>=97)&&(str<=122)))
		{
			words++;
		}

		else if((str>=48)&&(str<=58))        //What will happen if I change the second and the third 'if' into 'else if'?
		{
			number++;
		}

		else
		{
			others++;
		}
	}
		printf("\nwords %d  number %d space %d others %d\n\n",words,number,space,others);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?