TOPIC

Wrong Awnser 5%

🎈 ádisson téjo 🎈 asked 1 year ago

> O problema da Wrong Awnser 5% e não consigo enxergar o erro, me ajudem:~~
> #include <stdio.h>
> #include <string.h>
> #include <stdbool.h>
> 
> int y;
> int k, i, l;
> 
> int main(void) {
>   while(scanf("%d", &y)!=EOF){
>     int a[y], b[y], c[y], j[y];
>     char o[y], n[y][100], perdedores[y][100];
>     bool v[y];
>     char temp[100];
>     while(i<y){
>       scanf("%d %d=%d", &a[i], &b[i], &c[i]);
>       i++;
>     } 
>     i = 0;
>     while(i<y){
>       scanf("%s %d %c", n[i], &j[i], &o[i]);
>       j[i]--;
>       if(o[i] == '+'){
>         if(a[j[i]] + b[j[i]] == c[j[i]]){
>           v[i] = true;
>         }else{
>           v[i] = false;
>         }
>       }
>       if(o[i] == '-'){
>         if(a[j[i]] - b[j[i]] == c[j[i]]){
>           v[i] = true;
>         }else{
>           v[i] = false;
>         }
>       }
>       if(o[i] == '*'){
>         if(a[j[i]] * b[j[i]] == c[j[i]]){
>           v[i] = true;
>         }else{
>           v[i] = false;
>         }
>       }
>       if(o[i] == 'I'){
>         if(a[j[i]] + b[j[i]] != c[j[i]]){
>           if(a[j[i]] - b[j[i]] != c[j[i]]){
>             if(a[j[i]] * b[j[i]] != c[j[i]]){
>               v[i] = true;
>             }
>           }
>         }
>       }
>       i++;
>     }
>     i = 0;
>     k = 0;
>     while(i<y){
>       if(v[i] == false){
>         goto prox;
>       }
>       i++;
>     }
>     printf("You Shall All Pass!");
>     goto end;
>     prox:
>     i = 0;
>     while(i<y){
>       if(v[i] == true){
>         goto next;
>       }
>       i++;
>     }
>     printf("None Shall Pass!");
>     goto end;
>     next:
>     i = 0;
>     k = 0;
>     while(i<y){
>       if(v[i] == false){
>         strcpy(perdedores[k], n[i]); 
>         k++;
>       }
>       i++;
>     }
>     i = 0;
>     while(i<k-1){
>       if((strcmp(perdedores[i],perdedores[i+1])>0)){
>         strcpy(temp, perdedores[i+1]);
>         strcpy(perdedores[i+1],perdedores[i]);
>         strcpy(perdedores[i], temp); 
>       }
>       i++;
>     }
>     i = 0;
>     while(i<k){
>       if(i != 0){
>         printf(" ");
>       }
>       printf("%s", perdedores[i]);
>       i++;
>     }
>     end:
>     i = 0;
>     printf("\n");
>   }
>   return 0;
> }
> ```~~

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

  • feodorv replied 1 year ago

    Sorry, it's impossible to read your code. Couldn't you format it properly?