求调!
查看原帖
求调!
1032587
Alice_zhang楼主2024/2/25 19:22

哪里错了?

#include <iostream>
#include <string>
using namespace std;

string s[10];
int f[100];

int main()
{
    for(int i = 1; i <= 4; i++)
    {
        getline(cin, s[i]);
        for(int j = 0; j <= s[i].size() - 1; j++)
        {
            f[s[i][j] - 'A' + 1]++;
        }
    }
    int mx = 0;
    for(int i = 'A'; i <= 'Z'; i++)
    {
        if(f[i - 'A' + 1] > mx) mx = f[i - 'A' + 1];
    }
    for(int i = mx; i >= 1; i--)
    {
        for(int j = 'A'; j <= 'Z'; j++)
        {
            if(f[j - 'A' + 1] >= i) cout << "*";
            else cout << " ";
            if(j != 'Z') 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" << endl;
    return 0;
}

求调!

2024/2/25 19:22
加载中...