i could get correct answer for my code of reverse polish number when i give inputs,but codechef is showing result as wrong answer.....please someone help me

my code is:

#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,j,k,l=0;
	char str[400],array[400],output[400],haha[100][400];
	scanf("%d",&n);
	while(n-->0)
	{
		scanf("%s",&str);
		i=0;
		j=0;
		k=0;
		while(str[i]!='\0')
		{
			if(str[i]=='(')
			{
				array[j]='(';
				j++;
			}
			else if(str[i]=='*')
			{
				array[j]='*';
				j++;
			}
			else if(str[i]=='+')
			{
				array[j]='+';
				j++;
			}
			else if(str[i]=='-')
			{
				array[j]='-';
				j++;
			}
			else if(str[i]=='/')
			{
				array[j]='/';
				j++;
			}
			else if(str[i]=='^')
			{
				array[j]='^';
				j++;
			}
			else if(str[i]==')')
			{
				j--;
				while(array[j]!='(')
				{
					output[k]=array[j];
					k++;
					j--;
				}
			}
			else
			{
				output[k]=str[i];
				k++;
			}
			i++;
		}
		strcpy(haha[l],output);
		l++;
	}
	for(j=0;j<l;j++)
	{
		printf("\n");
		printf("%s",haha[j]);
	}
	return 0;
}

You should provide the link, to the question too. By the way, in the output, “printf(”\n"); printf("%s", haha[j])" is it correct? or it should be “printf(”%s", haha[j]); printf("\n")? Also, to insure that string is correctly read, you can make “scanf(”%d", &n);" as “scanf(”%d\n", &n);"