过不了!求助大佬
查看原帖
过不了!求助大佬
871166
rsrm123楼主2022/12/27 20:07
#include<stdio.h>
#include<stdbool.h>
char temp;
int jishu[30] = {0},i,j,control = 0,max;
int main(){
    while(true){
        scanf("%c",&temp);
        if(temp == '\n'){
            control++;
            if(control == 4){
                break;
            }
            continue;
        }
        if((temp>='A')&&(temp<='Z')){
            jishu[temp-64]++;
        }
    }
    for(i = 1;i<=26;i++){
        if(i == 1){
            max = jishu[i];
        }else{
            if(max<jishu[i]){
                max = jishu[i];
            }
        }
    }
    for(j = max;j>=1;j--){
        for(i = 1;i<=26;i++){
            if(i == 1){
                if(jishu[i] == j){
                    jishu[i]--;
                    printf("*");
                }else{
                    printf(" ");
                }
            }else{
                if(jishu[i] == j){
                    jishu[i]--;
                    printf(" *");
                }else{
                    printf("  ");
                }
            }
        }
        printf("\n");
    }
    for(i = 1;i<=26;i++){
        if(i == 1){
            printf("%c",i+64);
        }else{
            printf(" %c",i+64);
        }
    }
    return 0;
}

想不通为啥会超时!我看有好多题解跟我思想差不多,我感觉我还更快,但是结果就是超时了,有大佬解释一下麻

2022/12/27 20:07
加载中...