我的代码(算法借鉴题解)

#include <bits/stdc++.h>
using namespace std;
int bk[200];
main()
{
    string a;
    for(int i=0;i<4;i++)
    {
        getline(cin,a);
        for(int j=0;j<a.size();j++)
        if(isalpha(a[j]))
        bk[a[j]-'A']++;
    }
    int ans;
    for(int i=0;i<26;i++)
    ans=max(ans,bk[i]);
    for(int i=ans;i>0;i--)
    {
        for(int j=0;j<26;j++)
        {
            if(bk[j]>=i)
            cout<<"* ";
            else
            cout<<"  ";
        }
        cout<<"\n";
    }
    for(int i=0;i<26;i++)
    cout<<char('A'+i)<<" "; 
}

相关文章:

  • 2022-02-27
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-10-20
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2021-06-12
  • 2021-06-01
  • 2021-08-12
  • 2022-12-23
  • 2021-10-30
  • 2022-02-08
相关资源
相似解决方案