TÓPICO

Program output test on uDebug is correct

Marcelino Ioshio Kuzuhara perguntou 1 year ago

Hello dear friend, good afternoon,

I see no error in this code:

include

int main() { int n, i, aux; int cond1 = 0; int cond2 = 0;

do {
    scanf ("%i", &n);
if (n >= 1 && n <= 3000) break;
} while (1);

int f1[n], f2[n];

for (i = 0; i < n; i++)
{

do {
    scanf ("%i %i", &f1[i], &f2[i]);
    if (f1[i] >= 1 && f1[i] <= 1000) cond1 = 1;
    if (f2[i] >= 1 && f2[i] <= 1000) cond2 = 1;

    if (cond1 && cond2) break;
   } while (1);

    if (f1[i] < f2[i])
    {
     aux = f1[i];
     f1[i] = f2[i];
         f2[i] = aux;
    }  
}

for (i = 0; i < n; i++)
{
    do {
        aux = f1[i] % f2[i];     
        if (aux != 0)
        {
         f1[i] = f2[i];
         f2[i] = aux;
        } else break;
        } while (1);

printf ("%i\n", f2[i]);

}
return 0;

}

I test the program ouput on uDebug and it´s ok. Where´s the problem in code?

I wait for your response.

Thank you,

Lembre de não publicar soluções. Sua publicação pode ser revisada por nossos moderadores.

  • Marcelino Ioshio Kuzuhara respondido 1 year ago

    Hello dear friend, good evening,

    Why was the program I resubmitted approved without the consistency of the values, 1 <= N <= 3000 and 1 <= F1, F2 <= 1000? If value constraints are in the problem statement, shouldn't they be in the program code?

    I wait for response.

    Thank you,