代码:
#include<bits/stdc++.h>
using namespace std;
int a[26][105],cnt[1005],maxn;
string s,s1,s2,s3;
int n=4;
int main(){
getline(cin,s);
getline(cin,s1);
getline(cin,s2);
getline(cin,s3);
for(int j=0;j<s.length();j++){
a[s[j]-'A'][cnt[s[j]-'A']]=1;
cnt[s[j]-'A']++;
if(cnt[s[j]-'A']>=maxn){
maxn=cnt[s[j]-'A'];
}
}
for(int j=0;j<s1.length();j++){
a[s1[j]-'A'][cnt[s1[j]-'A']]=1;
cnt[s1[j]-'A']++;
if(cnt[s1[j]-'A']>=maxn){
maxn=cnt[s1[j]-'A'];
}
}
for(int j=0;j<s2.length();j++){
a[s2[j]-'A'][cnt[s2[j]-'A']]=1;
cnt[s2[j]-'A']++;
if(cnt[s2[j]-'A']>=maxn){
maxn=cnt[s2[j]-'A'];
}
}
for(int j=0;j<s3.length();j++){
a[s3[j]-'A'][cnt[s3[j]-'A']]=1;
cnt[s3[j]-'A']++;
if(cnt[s3[j]-'A']>=maxn){
maxn=cnt[s3[j]-'A'];
}
}
//
for(int i=maxn-1;i>=0;i--){
for(int j=0;j<26;j++){
if(j==25){
if(a[j][i]){
cout<<"*";
}else{
cout<<" ";
}
}else{
if(a[j][i]){
cout<<"* ";
}else{
cout<<" ";
}
}
}
cout<<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";
return 0;
}