求佬救救(无助),第二个AC了,其他全RE了(跪求)
查看原帖
求佬救救(无助),第二个AC了,其他全RE了(跪求)
1154144
yunyi1129楼主2024/1/12 21:15

#include <stdio.h> #include <math.h> int main() { char temp[400]; int i,j,k,cnt,flag=0;

i = 0;
while(flag!=4){
	temp[i]=getchar();
	if(temp[i]=='\n'){
		flag++;
	}
	i++;
}
temp[i] = '\0';
cnt = i;


int cap[27];
for(i=1;i<27;i++){
	cap[i] = 0;
}

for(i=0;i<cnt;i++){
	if(temp[i]>='A'&&temp[i]<='Z'){
		j = temp[i] - 'A' + 1;
		cap[j]++;
	}
}

int max=cap[1];
for(i=1;i<27;i++){
	if(max<cap[i]){
		max = cap[i];
	}
}
for(j=max;j>0;j--){
	for(k=1;k<27;k++){
		if(k==1){
			if(cap[k]==j){
				cap[k]--;
				printf("*");
			}else{
				printf(" ");
			}
		}else{
			if(cap[k]==j){
				cap[k]--;
				printf(" *");
			}else{
				printf("  ");
			}
		}
	}
	printf("\n");
}
printf("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;

}

2024/1/12 21:15
加载中...