wrong answer couldn't get it correct,I am a newbie

#include<stdio.h>

int main()
{
	int v,a,temp,arr[10001],t,k,c,i,j;
	v=0;
	scanf("%d",&t);
	while(t--)
	{
	for(a=0;a<10001;a++)
	{
		arr[a]=0;
	}
	scanf("%d",&i);
	for(j=0;j<i;j++)
	{
	 	scanf("%d",&k);
	 	arr[k]++;
	 	if(arr[k]>v)
	 	{
	 		v=arr[k];
	 		c=k;
	 	}
	 	else if(arr[k]==v)
	 	{
	 		if(k<c)
	 		{
	 		v=arr[k];
	 		c=k;
	 		}
	 	}
	}
    printf("\n%d %d",c,v);
    }
return 0;
}
1 Like

Why are you printing

printf("\n%d %d",c,v);

instead of

printf("%d %d\n",c,v);

?

Another proble in your code is that you are not initializing all values for test case, see the result when I simply switch the test cases from statement - http://ideone.com/RJoIse

you are initializing v at the starting of program so that it not getting set 0 for every test case, may be that be cause of WA.