TOPIC

Wrong answer (90%)

mantonio44 asked 6 years ago

Não sei mais o que fazer. Socorro

#include <stdio.h>
#define MAX 10005

int main(){
    int troca, igual;
    int a, b, carta;
    int ta, tb;
    int ali[MAX], bea[MAX];

    //Receber o tamanho dos vetores
    while(scanf("%d %d", &a, &b) == 2 && a){
        igual=0, troca=0;
        ta=0, tb=0;

        //Receber valores
        while (a){
            a--;
            scanf("%d", &carta);
            if (carta!=ali[ta-1]){
                ali[ta]=carta;
                ta++;
            }
        }
        while (b){
            b--;
            scanf("%d", &carta);
            if (carta!=bea[tb-1]){
                bea[tb]=carta;
                tb++;
            }
        }

        //Comparar os dois vetores e buscar por cartas iguais
        while (a!=ta && b!=tb ){
            if (ali[a]<bea[b]){
                a++;
            }
            else if (ali[a]>bea[b]){
                b++;
            }
            else{
                a++;
                b++;
                igual++;
            }
        }

        //Mostrar resultados na tela
        if (ta<tb || ta==tb && ta>0){
            printf("%d\n", ta-igual);
        }
        if (ta>tb && tb>0){
            printf("%d\n", tb-igual);
        }

    }
}

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

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