char使用gets(char)
string使用str.getline()
#include<bits/stdc++.h>
using namespace std;
int main(){
char alph[26],ALPH;
string p1,p2,p3,p4,text;
int i,j,pos,count[26],maxtimes;
i=0;
for(ALPH='A';ALPH<='Z';ALPH++){
alph[i]=ALPH;
i++;
}
getline(cin,p1);
getline(cin,p2);
getline(cin,p3);
getline(cin,p4);
text=p1+p2+p3+p4;
for(i=0;i<26;i++){
count[i]=0;
pos=text.find(alph[i]);
while(pos!=string::npos){
count[i]++;
pos=text.find(alph[i],pos+1);
}
}
maxtimes=0;
for(i=0;i<26;i++)maxtimes=max(maxtimes,count[i]);
for(i=maxtimes;i>=1;i--){
for(j=0;j<26;j++){
if(count[j]>=i)cout<<"* ";else if(count[j]<i)cout<<" ";
}
cout<<endl;
}
for(i=0;i<26;i++)cout<<alph[i]<<' ';
}