My submission is getting not getting accepted when it is correct?

#include<stdio.h>
int main()
{
int g,t,i,q;
unsigned int n;
scanf("%d",&t);
while(t–)
{
scanf("%d",&g);
while(g–)
{
scanf("%d %u %d",&i,&n,&q);
if(n%2==0)
{
printf("%u",n/2);
}
else if(n%2!=0 && i==1)
{
if(q==1)
printf("%u",n/2);
else
printf("%u",(n/2)+1);
}
else if(n%2!=0 && i==2)
{
if(q==1)
printf("%u",(n/2)+1);
else
printf("%u",n/2);
}
}
}
return 0;
}

It is because your algorithm is not passing all test cases.In other words your algorithm not able to generalize the problem.
In this case try a different algorithm.