TÓPICO
Presentation Error
jvpsierra perguntou 5 years ago
O código produz a saída esperada para todas as entradas de exemplo e disponíveis no uDebug. Porém, ao enviar recebo Presentation Error. Não sei como consertar.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LIM 1001
int main(void)
{
int n, i, j, k, cont, VetN[LIM], max, pos, TL;
char str[LIM], letras[LIM];
scanf("%d", &n);
getchar();
for(i = 0; i < n; i++)
{
gets(str);
max = 0;
for(j = 0; j < strlen(str); j++)
if(toupper(str[j]) >= 65 && toupper(str[j]) <= 90)
{
cont = 1;
for(k = j + 1; k < strlen(str); k++)
if(toupper(str[j]) == toupper(str[k]))
cont++;
if(cont > max)
max = cont;
VetN[j] = cont;
}
strcpy(letras, "\0");
TL = 0;
for(j = 0; j < strlen(str); j++)
if(VetN[j] == max)
{
pos = 0;
while(pos < TL && toupper(str[j]) > toupper(letras[pos]))
pos++;
for(k = TL; k > pos; k--)
letras[k] = letras[k - 1];
letras[pos] = tolower(str[j]);
TL++;
}
letras[TL] = '\0';
printf("%s\n", letras);
}
return 0;
}
Este tópico ainda não foi respondido. Seja o primeiro!