TOPIC

WA 5% (C++) - Please, help!

Danilo Ferreira asked 1 year ago

Please, help me!

#include <iostream>

using namespace std;

main() {
    int a, b, quociente, resto;

    cin >> a >> b;

    quociente = a / b;
    resto = a % b;

    if (resto < 0) {
        if (quociente > 0)
            quociente++;
        if (quociente < 0)
            quociente--;

        resto = a - (quociente * b);
    }

    cout << quociente << " " << resto << endl;
}

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

  • feodorv replied 1 year ago

    Please use uDebug to check your solution.

  • Spectre(CatsEye) replied 1 year ago

    please type return 0; at the end of the program...