daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top