TOPIC

WA 10% Saidas batem, não encontro o erro

Rodrigo Yamauchi asked 2 years ago

#include <stdio.h>
#include <string.h>

#define MAX 200

char frequencia(char f[]);

int main(){
        char f[MAX] = {0};
        int n;

        scanf("%d%*c", &n);

        while(n-->0){
            scanf("%[^\n]%*c", f);
            frequencia(f);
        }

    return 0;
}

char frequencia(char f[]){
    int i=0, c[123]={0}, maior;

    while(f[i]!='\0'){
        if(f[i]!=' ' || f[i]!='.'){ 
            c[f[i]]++;
            i++;
        }   
    }

    for(i=65;i<90;i++){
        c[i+32] = c[i] + c[i+32];
    }

    maior = c[97];

    for(i=97; i<123;i++){
        if(c[i]>maior){
            maior = c[i];
        }
    }

    for(i=97; i<123;i++){
        if(c[i] == maior){
            printf("%c", i);
        }
    }
    printf("\n");
}

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

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