Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include "stdio.h"
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[]) {
  7. freopen("division.in", "r", stdin);
  8. freopen("division.out", "w", stdout);
  9. int a, b = 0, q = 0;
  10. cin >> a >> b;
  11.  
  12. if (a >= 0 && b > 0) {
  13. q = a / b;
  14. } else if (a < 0 && b > 0) {
  15. if (a % b == 0)
  16. q = -1* (abs(a) / abs(b));
  17. else
  18. q = -1*(abs(a) / abs(b)) - 1;
  19. } else if (a > 0 && b < 0) { //ะดะฐ
  20. q = -1*(abs(a) / abs(b));
  21. } else if (a < 0 && b < 0) {
  22. if (a % b == 0)
  23. q = (abs(a) / abs(b));
  24. else
  25. q = abs(a) / abs(b) + 1;
  26. } else if (b == 0) {
  27. cout << "Na nol' delit' nel'zya!!!";
  28. }
  29. if (a == 0)
  30. q = 0;
  31. if (b != 0)
  32. cout << q;
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement