解题思路:
注意事项:
参考代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
getline(cin,str);
int size = str.length();
char *p = &str[0];
int ans_buffers = 0 , ans_space = 0, ans_nums= 0, ans_others = 0;
while(*p != '\0')
{
if((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z'))
{
ans_buffers++;
}
else if(*p == ' ')
{
ans_space++;
}
else if(*p >= '0' && *p <= '9')
{
ans_nums++;
}
else
ans_others++;
p++;
}
cout << ans_buffers << " " << ans_nums << " " << ans_space << " " << ans_others;
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:854 |
简单的a+b (C语言代码)浏览:573 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:534 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:349 |
简单的a+b (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:614 |
母牛的故事 (C语言代码)浏览:549 |
回文数字 (C语言代码)浏览:2510 |
A+B for Input-Output Practice (III) (C语言代码)浏览:421 |
【魔板】 (C++代码)浏览:1158 |