为什么这个代码是错的,请大佬解答一下
查看原帖
为什么这个代码是错的,请大佬解答一下
574849
biyi_mouse楼主2022/3/8 13:11
#include<iostream>
#include<string>
using namespace std;
int book[28];string a;
int main()
{
	while(cin>>a)
		for(int i=0;i<a.size();i++) 
			book[a[i]-'A'+1]++;
	int maxx=0;
	for(int i=1;i<=26;i++) maxx=max(maxx,book[i]);
	for(int i=maxx;i>=1;i--){
		for(int j=1;j<=26;j++)
			if(book[j]==i) {cout<<"*"<<" ";book[j]--;}
		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;
}
2022/3/8 13:11
加载中...