josiftepe

Untitled

Nov 1st, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.  
  9.     int a;
  10.     int b;
  11.     int c;
  12.     int i=0;
  13.     int x=0;
  14.     int y=0;
  15.  
  16.     cin >> a;
  17.     cin >> b;
  18.     cin >> c;
  19.    
  20.     int najmal_zbir = 1000000;
  21.     for(int i = 1; i <= 100; i += 1) {
  22.         int zbir = 0;
  23.         if(a - i < 0) {
  24.             zbir += i - a;
  25.         }
  26.         else {
  27.             zbir += a - i;
  28.         }
  29.         if(b - i < 0) {
  30.             zbir += i - b;
  31.         }
  32.         else {
  33.             zbir += b - i;
  34.         }
  35.         if(c - i < 0) {
  36.             zbir += i - c;
  37.         }
  38.         else {
  39.             zbir += c - i;
  40.         }
  41.         if(zbir < najmal_zbir) {
  42.             najmal_zbir = zbir;
  43.         }
  44.        
  45.     }
  46.     cout << najmal_zbir * 10 << endl;
  47.  
  48.  
  49.     return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment