

#include<iostream>
using namespace std;
int main()
{
char s[] = { 0 };
int n;
cin >> n;
char c;
int countA = 0;
int counta = 0;
int count1 = 0;
int countoth = 0;
int sum = 0;
while (n--)
{
cin >> c;
if (c>='A'&&c<='Z')
{
countA++;
}
else if (c >= 'a'&&c <= 'z')
{
counta++;
}
else if (c >= '0'&&c <= '9')
{
sum += c-48;
count1++;
}
else
{
countoth++;
}
}
cout << countA << " "<< counta << " "
<< count1 << " "<< countoth << endl;
if (countoth!=0)
{
cout << sum << endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
char str[100];
int i ;
int letterd,letterx,num ,other,sum=0;
char c;
cout<<"Please enter a string : ";
cin>>str;
letterd=letterx=num=other=0;
for( i= 0;str[i]!='\0'; i++)
{
c=str[i];
if((c>= 'A'&&c<='Z'))
letterd ++;
else if(c>='a'&& c<='z')
letterx ++;
else if (c>='0' && c<='9')
num++;
else other ++;
}
sum=letterd+letterx+num+other;
cout<<"letterd(大写)="<<letterd<<endl<<"letterx(小写)="<<letterx<<endl<<"num(数字)="<<num<<endl<<"other(其他)="<<other<<endl<<"sum(和)="<<sum;
return 0;
}
