求助!codeblocks编译案例过了,但是全wa了 QAQ
查看原帖
求助!codeblocks编译案例过了,但是全wa了 QAQ
646312
NoneVector楼主2022/8/11 17:00
#include <iostream>
#include <cstring>

using namespace std;

const int N = 110;

string s;

char a[N][26];  //a用来保存 *
int b[N];     //桶排序记录每个字幕出现的次数

int main()
{
    int max = -1; //max用来记录哪个字母出现的次数最多

    for(int i = 0; i < 4; i ++ )
    {
        getline(cin, s);
        for(int j = 0; j < s.length(); j ++ )
        {
            if(s[j] <= 'Z' && s[j] >= 'A')
            {
                int num = s[j] - 'A';
                b[num] ++;
                if(b[num] > max)
                {
                    max = b[num];
                }
            }
        }
    }
    for(int j = 0; j < 26; j ++ )
    {
        for(int i = max - 1; i >= 0; i -- )
        {
            if(b[j] > 0)
            {
                a[i][j] = '*';
                b[j]--;
            }
        }

    }

    for(int i = 0; i < max; i ++ )
    {
        for(int j = 0; j < 26; j ++ )
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }

    for(int i = 0; i < 26; i ++ )
    {
        char ch = 'A' + i;
        cout << ch << " ";
    }

}

2022/8/11 17:00
加载中...