View Code of Problem 66

#include <stdio.h>
int main()
{
    int a, b, i;
    int tmp = 1;
    while (scanf("%d%d", &a, &b) != EOF)
    {
        if (a / b == 1)
        {
            printf("%d\n", a / b);
        }
        else
        {
            for (i = 0; i <= a; i++)
            {
                if (a % i; i <= a; i++)
                {
                    tmp = i;
                    printf("%d%d\n", a / tmp, b / tmp);
                }
            }
        }
    }
    return 1;
}
/*
Main.cc: In function 'int main()':
Main.cc:16:21: warning: init-statement in selection statements only available with -std=c++17 or -std=gnu++17
                 if (a % i; i <= a; i++)
                     ^
Main.cc:16:23: warning: statement has no effect [-Wunused-value]
                 if (a % i; i <= a; i++)
                     ~~^~~
Main.cc:16:34: error: expected ')' before ';' token
                 if (a % i; i <= a; i++)
                    ~             ^
                                  )
Main.cc:16:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                 if (a % i; i <= a; i++)
                 ^~
Main.cc:16:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                 if (a % i; i <= a; i++)
                                    ^
Main.cc:16:39: error: expected ';' before ')' token
                 if (a % i; i <= a; i++)
                                       ^
                                       ;
Main.cc:5:9: warning: unused variable 'tmp' [-Wunused-variable]
     int tmp = 1;
         ^~~
*/

Double click to view unformatted code.


Back to problem 66