解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
#define Long 40
int main()
{
void scanf_str(char* a, int size, int* letter, int* num, int* space, int* other);
char a[Long]="";
int letter = 0, num = 0, space = 0, other = 0,size;
gets(a);
size = strlen(a);
scanf_str(a, size,&letter, &num, &space, &other);
printf("%d %d %d %d", letter, num, space, other);
return 0;
}
void scanf_str(char* a, int size, int* letter,int* num,int* space, int* other)
{
int i;
for (i = 0; i < size; i++)
{
if ((*(a + i) >= 'A' && *(a + i) <= 'Z') || (*(a + i) >= 'a' && *(a + i) <= 'z'))
(*letter)++;
else if (*(a + i) >= '0' && *(a + i) <= '9')
(*num)++;
else if (*(a + i) == ' ')
(*space)++;
else
(*other)++;
}
}
0.0分
0 人评分
【回文数(二)】 (C++代码)浏览:874 |
【回文数(二)】 (C语言代码)浏览:857 |
C二级辅导-统计字符 (C语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:1450 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:751 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:545 |
WU-格式化数据输出 (C语言代码)浏览:1755 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:481 |