Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

onp :getting wa help !!

$
0
0

getting correct ans on my pc compiler of question link text bt showing wrong ans on codechef . please help ..code is in c language


include<stdio.h>

int main() {

int n,i,j,top=-1;

char a[400],stack[400];
char temp;
scanf("%d",&n);
for(j=0;j<n;j++)
{
    scanf("%s",&a);

for(i=0;i<strlen(a);i++)
{
    while(a[i]=='(')
    {
        i++;
    }

    if(a[i]=='+' || a[i]=='-' || a[i]=='/' || a[i]=='*' || a[i]=='^')
        {
            temp=a[i];
            top++;
            stack[top]=temp;

        }
        else
            if(a[i]==')')
        {
            printf("%c",stack[top]);
            --top;


        }
        else
            printf("%c",a[i]);

        if(i==(strlen(a)-1) && top>-1)
        {
            printf("%c",stack[top]);
        }
}}
return 0;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>