Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "stdio.h"
- #include <cmath>
- using namespace std;
- int main(int argc, const char * argv[]) {
- freopen("division.in", "r", stdin);
- freopen("division.out", "w", stdout);
- int a, b = 0, q = 0;
- cin >> a >> b;
- if (a >= 0 && b > 0) {
- q = a / b;
- } else if (a < 0 && b > 0) {
- if (a % b == 0)
- q = -1* (abs(a) / abs(b));
- else
- q = -1*(abs(a) / abs(b)) - 1;
- } else if (a > 0 && b < 0) { //ะดะฐ
- q = -1*(abs(a) / abs(b));
- } else if (a < 0 && b < 0) {
- if (a % b == 0)
- q = (abs(a) / abs(b));
- else
- q = abs(a) / abs(b) + 1;
- } else if (b == 0) {
- cout << "Na nol' delit' nel'zya!!!";
- }
- if (a == 0)
- q = 0;
- if (b != 0)
- cout << q;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement