代码:
#include<bits/stdc++.h>
using namespace std;
int ccnt[30],last[405];
string ans[405];
int main()
{
string s,a,b,c,d;
getline(cin,a);
getline(cin,b);
getline(cin,c);
getline(cin,d);
s=a+b+c+d;
for(int i=0;i<s.size();i++)
{
if(s[i]!=' ')
{
ccnt[s[i]-'A']++;
}
}
int maxx=-1;
for(int i=0;i<26;i++)
{
maxx=max(maxx,ccnt[i]);
}
for(int i=maxx;i>=1;i--)
{
for(int j=0;j<26;j++)
{
if(ccnt[j]-i>=0)
{
ans[i]+="*";
last[i]=j;
}
else
{
ans[i]+=" ";
}
ans[i]+=" ";
}
}
for(int i=maxx;i>=1;i--)
{
cout<<ans[i]<<endl;
}
cout<<"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"<<endl;
}