题目:
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char str[1001];
int a=0,b=0,c=0;
fgets(str,sizeof(str),stdin);
for(int i=0;i<strlen(str);i++)
{
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U'){
a++; //大小写辅音字母
}
else if(str[i]>=' '&&str[i]<='/') b++; //排除ascll码32-47字符的干扰
else
c++;
}
cout<<a<<" "<<c<<endl;
return 0;
}
输入样例:
You're not a varsity athlete the first time you play a new sport.
输出样例:
20 31
主要知识点:
else if(str[i]>=' '&&str[i]<='/') b++; //排除ascll码32-47字符的干扰