大佬们求助,看看蒻蒻哪里写错了。
查看原帖
大佬们求助,看看蒻蒻哪里写错了。
802760
super_LD楼主2022/11/7 12:41
#include <iostream>
#include <string>
using namespace std;
int max(int x, int y)
{
    if (x < y)x = y;
    else x = x;
    return x;
}
int main()
{
    string str1;
    int a[26] = { 0 }, ans = 0;
    char n = 'A';
    for (int i = 0; i < 4; i++)
    {
        getline(cin, str1);
        for (int j = 0; j < str1.length(); j++)
        {
            if (str1[j] >= 'A' && str1[j] <= 'Z')
                a[str1[j] - 'A']++;
        }
    }
    for (int i = 0; i < 26; i++)
    {
        ans = max(ans, a[i]);
    }
    for (int i = ans; i > 0; i++)
    {
        for (int j = 0; j < 51; j++)
        {
            if (j % 2 == 0)
            {
                if (a[j / 2] >= i)cout << "*";
                else cout << " ";
            }
            else cout << " ";
        }
    }
    for (int i = 0; i < 51; i++)
    {
        char m = n + i / 2;
        if (i % 2 == 0)cout << m;
        else cout << " ";
    }
    return 0;
}
2022/11/7 12:41
加载中...