为什么0分??样例没错
查看原帖
为什么0分??样例没错
1073866
Coding_wang楼主2023/10/3 12:04
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a[26]={0};
	string str;
	for(int i=0;i<4;i++){
		getline(cin,str);
		for(int j=0;j<str.length();j++){
			if(str[j]>='A'&&str[j]<='Z'){
				a[str[j]-'A']++;
			}
		}
	}
	int maxn=a[0];
	for(int h=0;h<25;h++){
		if(a[h+1]>a[h]){
			maxn=a[h+1];
		}
	}
	for(int i=maxn;i>0;i--){
		for(int j=0;j<26;j++){
			if(a[j]>=i){
				if(j!=25){
					cout<<"*"<<" ";
				}else{
					cout<<"*";
				}
			}else{
				if(j!=25){
					cout<<" "<<" ";
				}else{
					cout<<" ";
				}
			}
		}
		cout<<endl;
	}
	for(int i=0;i<26;i++){
		if(i!=25){
			cout<<(char)(i+'A')<<" ";
		}else{
			cout<<"Z";
		}
	}
	return 0;
}
2023/10/3 12:04
加载中...