Advertisement
Josif_tepe

Untitled

Mar 17th, 2024
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int global_max = 0, global_min = 6001;
  8.     int tmp_max = 0, tmp_min = 6001;
  9.     int x;
  10.     int nuli = 0;
  11.    
  12.     while(cin >> x) {
  13.         if(x == 11111) {
  14.             break;
  15.         }
  16.         if(x == 0 and nuli == 0) {
  17.             nuli = 1;
  18.             continue;
  19.         }
  20.         if(x != 0 and nuli > 0) {
  21.             tmp_max = max(tmp_max, x);
  22.             tmp_min = min(tmp_min, x);
  23.         }
  24.         if(x == 0) {
  25.             global_max = max(global_max, tmp_max);
  26.             global_min = min(global_min, tmp_min);
  27.             tmp_max = 0;
  28.             tmp_min = 6001;
  29.  
  30.         }
  31.     }
  32.     cout << global_max - global_min << endl;
  33.     return 0;
  34. }
  35.  
  36. // 650 1500 0 600 1000 2000 0 800 1500 0 1500 1300 1400 11111
  37. /*
  38. tmp_min = 800
  39. tmp_max = 1500
  40.  
  41. global_min = 600
  42. global_max = 2000
  43.  
  44.  
  45. */
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement