Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int max = -2000000000;
- int min = 2000000000;
- int max2 = -2000000000;
- int min2 = 2000000000;
- int dali_sme_ja_vnele_prvata_nula = -1;
- while(true) {
- int broj;
- cin >> broj;
- if(broj == 11111) {
- break;
- }
- if(dali_sme_ja_vnele_prvata_nula != -1 and broj != 0) {
- if(max < broj) {
- max = broj;
- }
- if(min > broj) {
- min = broj;
- }
- }
- if(broj == 0 and dali_sme_ja_vnele_prvata_nula == 1) {
- if(max2 < max) {
- max2 = max;
- }
- if(min2 > min) {
- min2 = min;
- }
- max = -2000000000;
- min = 2000000000;
- }
- if(broj == 0) {
- dali_sme_ja_vnele_prvata_nula = 1;
- }
- }
- cout << max2 - min2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement