寻求大佬的帮助
  • 板块灌水区
  • 楼主Kratos_Charger
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/12/22 12:32
  • 上次更新2023/12/22 12:38:09
查看原帖
寻求大佬的帮助
841550
Kratos_Charger楼主2023/12/22 12:32

P1958为什么错了??

#include<bits/stdc++.h>
using namespace std;
string s;
int maxl=-1,a[30];
int main()
{
	for(int i=1;i<=4;i++){
		cin>>s;
		getline(cin,s);
		for(int j=1;j<=s.size();j++){
			if(s[j]>='A'&&s[j]<='Z')
		        a[s[j]-'A']++;
		}
	}
	for(int i=1;i<=26;i++)
		maxl=max(a[i],maxl);
	for(int i=maxl;i>=0;i--)
	{
		for(int j='A';j<='Z';j++){
			if(a[j-'A']>i) cout<<"*";
			else cout<<" ";
			cout<<" ";
		}
		cout<<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;
}

输出少两行◑﹏◐

2023/12/22 12:32
加载中...