Sample Input
abcd efg 12345
Sample Output
5 7 3
Hint
有5个数字,7个字母,和3个非数字字母(两个空格,一个回车)
回车键怎么搞?还有以文件结束符结尾啥意思
Sample Input
abcd efg 12345
Sample Output
5 7 3
Hint
有5个数字,7个字母,和3个非数字字母(两个空格,一个回车)
回车键怎么搞?还有以文件结束符结尾啥意思
// Q765245.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <stdio.h>
#include <string.h>
int main()
{
char buff[1000];
int letter = 0;
int number = 0;
int other = 0;
while (true)
{
char * p = gets_s(buff, 1000);
if (p == NULL) break;
other++;
for (int i = 0; i < strlen(buff); i++)
{
if (buff[i] >= 'A' && buff[i] <= 'Z')
letter++;
else if (buff[i] >= 'a' && buff[i] <= 'z')
letter++;
else if (buff[i] >= '0' && buff[i] <= '9')
number++;
else
other++;
}
}
printf("%d %d %d\n", number, letter, other);
}