在一行中输出文章中的英文大写字母、小写字母、数字、空格以及其他字符的个数,用空格隔开。
请注意行尾输出换行。
样例输入:
I am a program.
This is the second line!
And this is the last line........
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char a[3][80];
void niuma();
int s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0;
void main()
{
for (int i = 0; i < 3; i++)
{
gets_s(a[i]);//gets可以输入数字,但是是字符串专用的,要想输入数字不能用int型数组
}
niuma();
printf("%d %d %d %d %d", s1, s2, s3, s4, s5);
}
void niuma()
{
int j = 0;
for (int i = 0; i < 3; i++)
{
for (; j <strlen(a[i]); j++)
{
//不能使用'65',来表示只能用65,或者‘A’‘a’来表示
if (a[i][j] >=65 && a[i][j] <= 90) { s1++; }
//不能使用'65',来表示只能用65,或者‘A’‘a’来表示
else if (a[i][j] >= 'a' && a[i][j] <= 'z') { s2++; }
else if (a[i][j]>='0'&&a[i][j]<='9') { s3++; }
else if (a[i][j] == ' ') { s4++; }
//出来这三类其他都是其他字符else可以作为前三个分支总的反面。
else { s5++; }
}
j = 0;
}
}
结果: