解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
int main()
{
char n[100];
int i,word=0,num=0,space=0,other=0;
gets(n);
for(i=0;i<strlen(n);i++)
{
if(n[i]>='a'&&n[i]<='z'||n[i]>='A'&&n[i]<='Z')
word++;
else if(n[i]>='0'&&n[i]<='9')
num++;
else if(n[i]==' ')
space++;
else
other++;
}
cout<<word<<" "<<num<<" "<<space<<" "<<other<<endl;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:653 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:633 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:277 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:456 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1229 |
【简单计算】 (C语言代码)浏览:622 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:916 |
水仙花 (C语言代码)浏览:1053 |
数对 (C语言代码)浏览:702 |
1014题解浏览:485 |