解题思路:
注意事项:
参考代码:
#include<stdio.h>
void Statistic(char* str,int n)
{
int i;
int character = 0;
int number = 0;
int space = 0;
int other_character = 0;
for (i = 0; i < n; i++)
{
if ((((*str) >= 65) && ((*str) <= 90)) || (((*str) >= 97) && ((*str) <= 122)))
{
character++;
}
else if(((*str) >= 48) && ((*str) <= 57))
{
number++;
}
else if ((*str) == 32)
{
space++;
}
else
{
other_character++;
}
str++;
}
printf("%d %d %d %d", character, number, space, other_character);
}
int main()
{
char str[100];
gets(str);
Statistic(str, strlen(str));
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:646 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:518 |
永远的丰碑 (C语言代码)浏览:526 |
矩形面积交 (C语言代码)浏览:1314 |
输入输出格式练习 (C语言代码)浏览:850 |
简单的a+b (C语言代码)浏览:830 |
拆分位数 (C语言代码)浏览:522 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:565 |
小O的乘积 (C++代码)浏览:755 |
10月月赛题解浏览:536 |