#include<bits/stdc++.h>
using namespace std;
string s;
int temp,STEMP;
int num[30];
int TEMP[30];
char word[27] = {'a', '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'};
int main() {
for (int i = 0; i < 4; i++) {
getline(cin,s);
for (int i = 0; i < s.length(); i++) {
if (s[i] >= 'A' && s[i] <= 'Z') {
temp = s[i] - 64;
num[temp]++;
TEMP[temp]++;
}
}
}
sort(TEMP, TEMP + 27);
STEMP = TEMP[26];
for (int i = 1; i <= TEMP[26]+1; i++) {
for (int j = 1; j <= 26; j++) {
if (num[j] < STEMP && STEMP!=0) {
if (j <= 25)
cout << " ";
else
cout << " ";
}
else if (num[j] >= STEMP && STEMP != 0) {
if (j <= 25)
cout << "* ";
else
cout << "*";
}
else if (STEMP == 0) {
if (j <= 25) {
cout << word[j] << " ";
}
else {
cout << word[j];
}
}
}
STEMP--;
cout << endl;
}
system("pause");
return 0;
}
P1598 垂直柱状图
最新推荐文章于 2024-04-02 22:58:38 发布