Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x, y, sum = 0;
  6. cin >> x >> y;
  7. if (x > y) {
  8. int temp = 0;
  9. if (x % 2 == 0)
  10. {
  11. temp = x / 2;
  12. sum += temp + temp / 2 - 1;
  13. }
  14. else if (x % 2 == 1) {
  15. temp = x / 2 + 1;
  16. sum += temp + temp / 2 - 1;
  17. }
  18. }
  19. else if (y > x)
  20. {
  21. int temp = 0;
  22. if( y % 2 == 0)
  23. {
  24. temp = y / 2;
  25. sum += temp + temp / 2 - 1;
  26. }
  27. else if (y % 2 == 1) {
  28. temp = y / 2 + 1;
  29. sum += temp + temp / 2 - 1;
  30. }
  31. }
  32. cout << sum;
  33. system("pause");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement