解题思路:
用ctype.h的字符判断函数
注意事项:
参考代码:
#include<stdio.h>
#include<ctype.h>
int main(void)
{
int i_letter=0;
int i_number=0;
int i_space=0;
int i_other=0;
int c;
printf("Please enter a string:");
while((c=getchar())!='\n')
{
if(isalpha(c))
i_letter++;
else if(isdigit(c))
i_number++;
else if(isblank(c))
i_space++;
else
i_other++;
}
printf("%d %d %d %d\n",i_letter,i_number,i_space,i_other);
return 0;
}
0.0分
0 人评分
你的开发任务 (C++代码)写到一半,等有心情回来补全浏览:887 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:595 |
C语言训练-求具有abcd=(ab+cd)2性质的四位数 (C语言代码)浏览:1372 |
C语言程序设计教程(第三版)课后习题12.1 (C语言代码)浏览:987 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:867 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:907 |
WU-判定字符位置 (C++代码)浏览:1406 |
Wu-求圆的面积 (C++代码)浏览:1892 |
1128题解(返回值为数组的情况)浏览:473 |
Tom数 (C语言代码)浏览:495 |