TOPIC

Wrong answer (100%) Linguagem C

Eduardo Camargo asked 2 months ago

A saida está exatamente igual, fiz a conversão para int pois me disseram que o programa nao aceitava %.0f sei que o codigo esta meio confuso foderia usar somente 2 variaveis nao precisava nescessariamente dessa variavel aux

Código

#include <stdio.h>

int main(){

    float aux=0;
    int i, i2;

    while(i<=11)
    {
        for(i2=1; i2<=3; i2++){
            if(i == 1 || i == 6 || i == 11)
                printf("I=%i J=%i\n", (int)aux, (int)aux+i2);

            else
                printf("I=%.1f J=%.1f\n", aux, i2+aux);
        }

        aux+=0.2;
        i++;
    }
    return 0;
}
Saída

I=0 J=1
I=0 J=2
I=0 J=3
I=0.2 J=1.2
I=0.2 J=2.2
I=0.2 J=3.2
I=0.4 J=1.4
I=0.4 J=2.4
I=0.4 J=3.4
I=0.6 J=1.6
I=0.6 J=2.6
I=0.6 J=3.6
I=0.8 J=1.8
I=0.8 J=2.8
I=0.8 J=3.8
I=1 J=2
I=1 J=3
I=1 J=4
I=1.2 J=2.2
I=1.2 J=3.2
I=1.2 J=4.2
I=1.4 J=2.4
I=1.4 J=3.4
I=1.4 J=4.4
I=1.6 J=2.6
I=1.6 J=3.6
I=1.6 J=4.6
I=1.8 J=2.8
I=1.8 J=3.8
I=1.8 J=4.8
I=2 J=3
I=2 J=4
I=2 J=5

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

  • Wellerson Salvatore replied 2 months ago

    sua saida está assim no inicio:

    I=0.0 J=1.0
    I=0.0 J=2.0
    I=0.0 J=3.0
    I=0 J=1
    I=0 J=2
    I=0 J=3
    I=0.4 J=1.4
    I=0.4 J=2.4
    I=0.4 J=3.4

    deveria ser assim:

    I=0 J=1
    I=0 J=2
    I=0 J=3
    I=0.2 J=1.2
    I=0.2 J=2.2
    I=0.2 J=3.2

    e assim por diante...