TOPIC

Wrong answer (5%) - C -

mfigueiredo7 asked 4 years ago

Alguém poderia dar uma luz? Fiz esse código e está dando erro ainda, porém está tudo funcionando como deveria "/.


#include <stdio.h>
#include <math.h>

int rafael(int x, int y){
    //(3x)² + y²
    int total = 0;
    total = ((pow(3*x, 2)) + (pow(y, 2)));
    return total;
}

int beto(int x, int y){
    //2(x²) + (5y)²
    int total = 0;
    total = (2 * (pow(x, 2)) + (pow(5 *  y, 2)));
    return total;
}

int carlos (int x, int y){
    //-100x + y³.
    int total = 0;
    total = (-100 * x + (pow(y, 3)));
    return total;
}

int compara(int r, int b, int c){

    if(c > r && c > b)
        printf("Carlos ganhou");
    else if(r > b && r > c)
        printf("Rafael ganhou");
    else if(b > c && b > r)
        printf("Beto ganhou");
}

int main()
{
    int N, x, y, r, b, c, maior, i = 0;
    scanf("%d", &N);
    while(i < N){
        i++;
        scanf("%d", &x);
        scanf("%d", &y);
        r = rafael(x, y);
        b = beto(x, y);
        c = carlos(x, y);
        maior = compara(r, b, c);
    }
    printf("\n");
    return 0;
}

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

  • SamaraRamos replied 4 years ago

    Os valores x e y tem que ser lidos em uma linha única

  • RafaelGuedesICET replied 2 years ago

    Faltava colocar \n após cada "ganhou" e remover o último \n. Assim a saída ficaria igual ao exemplo.

  • alexis__t replied 4 years ago

    O seu método int compara(), não retorna nada, por ser um metodo int ele espera um valor int, troque de int para void e você ira precisar remover a variavel (maior) que recebe esse método. Com isso, se sua lógica estiver correta, irá receber Accepted.

  • mfigueiredo7 replied 4 years ago

    Samara, alterei o código para ler em somente uma linha mas mesmo assim não funcionou