Advertisement
Josif_tepe

Untitled

Mar 25th, 2022
1,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6.     int max = -2000000000;
  7.     int min = 2000000000;
  8.     int max2 = -2000000000;
  9.     int min2 = 2000000000;
  10.     int dali_sme_ja_vnele_prvata_nula = -1;
  11.     while(true) {
  12.         int broj;
  13.         cin >> broj;
  14.         if(broj == 11111) {
  15.             break;
  16.         }
  17.         if(dali_sme_ja_vnele_prvata_nula != -1 and broj != 0) {
  18.             if(max < broj) {
  19.                 max = broj;
  20.             }
  21.             if(min > broj) {
  22.                 min = broj;
  23.             }
  24.         }
  25.         if(broj == 0 and dali_sme_ja_vnele_prvata_nula == 1) {
  26.             if(max2 < max) {
  27.                 max2 = max;
  28.             }
  29.             if(min2 > min) {
  30.                 min2 = min;
  31.             }
  32.             max = -2000000000;
  33.             min = 2000000000;
  34.         }
  35.         if(broj == 0) {
  36.             dali_sme_ja_vnele_prvata_nula = 1;
  37.         }
  38.        
  39.     }
  40.     cout << max2 - min2 << endl;
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement