#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int size;
int count=0;
int n,i;
int *str = (int *) malloc(sizeof(int));
size=sizeof(int);
n=0;
do
{
scanf("%d",&n);
if(count==0)
{
str[0]=n;
++count;
}
else
{
size+=sizeof(int);
str = (int *) realloc(str, size);
str[count++]=n;
}
}while(n<99);
for(i=0;i<count;i++)
{
if(str[i]==42)
break;
else
printf("%d\n",str[i]);
}
free(str);
return(0);
}
Hello guys, I'm new at spoj. I solved this TEST problem. It's working fine in my pc by spoj is telling me - "wrong answer". I cannot figure out what's wrong in the code. So, please help. Thanks in advance.