ACM题，不太理解哪出错了，求帮忙

Input
The first line of the input is the number of test cases. Then some test cases followed.
Each test case contains only one line, indicating the string mentioned above.
You can assume there is only lower case letters in the string. The length of the string is more than 0 and no more than 100.
Output
You should output one line for each test case, indicating the most frequent letters. Please note there may be more than one such letter, so you should output all of them, and these letters should be in the same order as the alphabet, that is, 'a', 'b', 'c', 'd' ... 'z'.
Sample Input
2
abcda
tjucstju
Sample Output
a
jtu

#include
int seq;
int result = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int t;
int main()
{
int x, i, j,h=1;
scanf("%d", &x);
getchar();
for (i = 0,j=0; i {
while (scanf("%c", &seq[j]) != EOF&&seq[j]>=97&&j {
result[seq[j] - 97]++;
j++;
}
if (j == 0)
{
i = 0;
continue;
}
if (result > result)
{
t = 0;
}
else if (result < result)
t = 1;
else
{
t = 0;
t = 1;
h = 2;
}
for (j = 2; j < 26; j++)
{
if (result[j]>=result[t])
{
if (result[j] == result[t])
{
t[h] = j;
h++;
}
else
{
t = j;
h = 1;
}
}
}
for (j = 0; j < h; j++)
{
printf("%c", t[j] + 97);
t[j] = 0;
}
printf("\n");
for (j = 0; j < 26; j++)
{
result[j] = 0;
}
i++;
j = 0;
}
return 0;
}

1个回答 