一上午了,测试用例全都对;才40分!!!哭了!!!
查看原帖
一上午了,测试用例全都对;才40分!!!哭了!!!
677042
acheng_up楼主2022/2/15 11:57
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(){
int aa[26],i,j;
for(i=0;i<26;i++){
	aa[i]=0;
}

for(i=0;i<4;i++){
	char a[200];
	gets(a);
	
	for(j=0;j<strlen(a);j++){
		if(a[j]<='Z'&&a[j]>='A'){
		
			aa[a[j]-'A']++;
		}
	}
}

int max=aa[0];
	for(i=0;i<26;i++){
		if(aa[i]>max){
			max=aa[i];
		}

	}


char s[max+1][26];


for(i=0;i<26;i++){
	for(j=max-1;j>max-1-aa[i];j--){
		s[j][i]='*';
	}
}
int ii,flag;
for(j=0;j<max;j++){
for(i=0;i<26;i++){
		flag=0;
     for(ii=i+1;ii<26;ii++){
     	if(s[j][ii]=='*'){
     		flag=1;break;
     	}
     }
		if(s[j][i]=='*'){
			if(flag==1){
				cout<<s[j][i]<<" ";
			}else{
				cout<<s[j][i];
			}
			
		}else if(flag==1){
			cout<<"  ";
		}else{
			
		}

	
	}
	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";
}
2022/2/15 11:57
加载中...