Enter a string, count the number of occurrences of each character, and output the results in alphabetical order
Brief description
1. Language: C or C++;
2. Example:
input: codebook/ (input string ends with a symbol/);
output: A0 B1C1D1E1 F0G0H0I0G0 K1 L0M0N0 O3 P0Q0R0S0T0U0V0W0X0Y0Z0
Code (runnable)
#include <iostream>
using namespace std;
void main()
{
char m='a';
int i;
int a,str[26]={
0};
while(m!='/') //输入字符串以符号/结尾
{
cin>>m;
a=m;
if(a>=65&&a<=90)
str[a-65]++;
if(a>=97&&a<=122)
str[a-97]++;
}
for(i=0;i<26;i++)
{
m=65+i;
cout<<m<<str[i];
}
cout<<endl;
}