TOPIC

WA 100% está correto com os casos do udebug

Calixto asked 7 months ago

#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>

int maiorin(int vet[200]){
    int maior = 0;
    int i = 200;

    while(i--)
        if(maior<vet[i])
            maior = vet[i];

    return maior;
}

char *codes(int vet[200]){

    int i = 26;
    int j = 0;
    char *str = (char*) malloc(26*sizeof(char));
    int maior = maiorin(vet);

    while(i--)
        str[i] = 0;

    while(i<200){

        if(vet[i]==maior)
            str[j++] = (char)i;
        i++;
    }

    return str;
}

int main(){

    int n = 0;
    int i = 0;
    char c = 0;
    char *str = NULL;
    int vet[200] = {0};

    scanf("%d",&n);
    getchar();

    while(n--){

        i = 200;
        while(i--)
            vet[i] = 0;

        while((scanf("%c",&c)!=EOF) && (c!='\n'))
            if(isalpha(c))
                vet[tolower(c)]++;

        str = codes(vet);

        printf("%s\n",str);
    }

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.