TOPIC

what the :) with this problem? what is 5% eror?

Ihsan Ahmad asked 11 months ago

#include <iostream>
#include <iomanip>

using namespace std;

int main()

{
    int a, b, q, r, c, d, e, f;

    cin >> a >> b;

    if(a > 0 && b > 0)
    {
        q = a / b;
        r = a % b;
        cout << q << " " << r << endl;
    }

    if(a < 0 && b < 0)
    {
        c = a / b;
        q = c + 1;
        d = q * b;
        r = (d-a) * (-1);
        cout << q << " " << r << endl;
    }

    if(a > 0 && b < 0)
    {
        q = a / b;
        r = a % b;
        cout << q << " " << r << endl;
    }

    if(a < 0 && b > 0)
    {
        c = a / b;
        q = c - 1;
        d = q * b;
        r = (d-a) * (-1);
        cout << q << " " << r << endl;
    }
    if(a == 0 || b == 0)
    {
        cout << 0 << " " << 0 << endl;
    }

    return 0;
}

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

  • Paulo Diogo replied 11 months ago

    Man, the secret is to be simple.