TOPIC

Wrong Answer 40%

Wellington Levi asked 2 years ago

Não consigo ver o erro no meu programa, sabe em qual teste daria errado?

#include<stdio.h>
#include<string.h>
int main()
{
   freopen("in.txt","r",stdin);
    long int i,j,k,t,x,y,z,v,p,e;
    char r,nome[51],op[50],vc[50][51],pr[50][51];
    while(scanf("%ld",&t)!=EOF)
    {
        v=0;
        p=0;
        for(i=0;i<t;i++)
        {
            scanf("%ld %ld=%ld ",&x,&y,&z);
            if((x+y)==z)
                op[i]='+';
                else
            if(x-y==z)
                op[i]='-';
                else
            if(x*y==z)
                op[i]='*';
                else
                op[i]='I';
        }
        j=0;
        k=0;
        for(i=0;i<t;i++)
        {
            scanf("%s",nome);
            scanf("%ld ",&e);
            scanf("%c",&r);
            if(r==op[e-1])
            {
                v++;
                strcpy(vc[j],nome);
                j++;
            }
            else
            {
                p++;
                strcpy(pr[k],nome);
                k++;
            }
        }

            if(j==t)
                puts("You Shall All Pass!");
            else
            if(k==t)
                puts("None Shall Pass!");
            else
            {
                for(i=0;i<k-1;i++)
                    for(j=0;j<k;j++)
                     if(strcmp(pr[i],pr[j])==1)
                     {
                         strcpy(nome,pr[j]);
                         strcpy(pr[j],pr[i]);
                         strcpy(pr[i],nome);
                     }
                for(i=0;i<k;i++)
                    if(i<k-1)
                    printf("%s ",pr[i]);
                else
                    printf("%s\n",pr[i]);
            }
    }
    return 0;
    }

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.