这怎么还不对?
查看原帖
这怎么还不对?
856309
oiyang楼主2023/6/29 18:27

明明末尾一点空格都没有啊

#include <bits/stdc++.h>
using namespace std;
string s;
map<char,int> mapp;
int maxn=0;
int main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=4;i++)
	{
		getline(cin,s);
		for(const char ch : s)
		{
			if (!isalpha(ch)) {
				continue;
			}
			if (mapp.find(ch) == mapp.end()) {
				mapp[ch] = 1;
			}
			else {
				mapp[ch]++;
			}
		}
	}
	for(auto it=mapp.begin();it!=mapp.end();it++)
	{
		maxn=max(maxn,it->second);	
	}
	for(int i=1;i<maxn;i++)
	{
		for(int j=1;j<=25;j++)
		{
			if(maxn-i>mapp['A' + j - 1]) 
				cout<<"  ";
			else
				cout<<"* ";
		}
		if(maxn-i>mapp['A'+25])
			cout<<" ";
		else
			cout<<"*";
		cout<<endl;
	}
	for(int i=0;i<=24;i++)
		cout<<(char)('A'+i)<<" ";
	cout<<"Z";
	return 0;
}
2023/6/29 18:27
加载中...