I 'm a beginner in ACM contest. I have completed this problem :
http://acm.uva.es/archive/nuevoportal/d ... php?p=4341
I run sample input in my pc, it showed the correct output. But when I submit, the result is "RUN TIME ERROR"
Would you like to review my code for me?
This is my code
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
int n;
int count = 1;
int dem = 0;
int pre = -1;
int max = -1;
int val;
char c;
int flag = 0;
char *st;
char *temp;
scanf("%d%c",&n,&c);
while (count<=n)
{
gets(st);
count++;
temp = strtok(st," ");
while (temp)
{
val = strlen(temp);
if (pre == -1)
{
pre = val;
dem = 1;
}
else
{
if (val == pre)
{
dem++;
}
else
{
if (dem > max)
max = dem;
dem = 1;
pre = val;
}
}
temp = strtok(NULL," ");
}
if (dem > max)
max = dem;
printf("%d\n",max);
max = 0;
dem = 1;
pre = -1;
}
return 0;
}