33,311
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
int sta(char c);
int main()
{
int number=0,letter=0,other=0;
char str[]={'a','e','4','%','8','!','F','1',':','/'};
for(int i=0;i<sizeof(str);i++)
{
cout<<str[i];
switch(sta(str[i]))
{
case 0:
number++;
break;
case 1:
letter++;
break;
case 2:
other++;
break;
}
}
cout<<endl<<number<<endl;
cout<<letter<<endl;
cout<<other<<endl;
return 0;
}
int sta(char c)
{
if(c>=48&&c<=57)return 0;
if((c>=65&&c<=90)||(c>=97&&c<=122))return 1;
return 2;
}