artemgf

Такси

Mar 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <math.h>
  5. #include <algorithm>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     int a, b, c, d;
  13.  
  14.     cin >> a >> b >> c >> d;
  15.  
  16.     while (c !=-9000)
  17.     {
  18.         if (c <= a)
  19.         {
  20.             cout << a;
  21.             break;
  22.         }
  23.         a += b;
  24.         if (c <= a)
  25.         {
  26.             cout << c;
  27.             break;
  28.         }
  29.         c -= d;
  30.         if (c <= a)
  31.         {
  32.             cout << a;
  33.             break;
  34.         }
  35.     }
  36.  
  37.  
  38.     _getch();
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment