为啥样例过了,还是全红啊,求助!
查看原帖
为啥样例过了,还是全红啊,求助!
1230024
Lye16楼主2025/2/7 16:09
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a[26] = { 0 };
	for (int i = 0; i < 4; i++) {
		string s;
		getline(cin, s);
		for (int j = 0; j < s.size(); j++) {
			if (s[j] >= 65 && s[j] <= 90) {
				a[s[j] - 65]++;
			}
		}
	}
	int max = -1;
	for (int i = 0; i < 26; i++) {
		if (a[i] > max)max = a[i];
	}
	int m = max;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < 26; j++) {
			if (a[j] == max) {
				cout << "* ";
				a[j]--;
			}
			else cout << "  ";
		}
		max--;
		cout << "\b" << 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";
	return 0;
}
2025/2/7 16:09
加载中...