Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     setlocale(LC_ALL, "rus");
  6.     int s, min = 1001, max = -1, temp, count = 0, tempbefore, smax = 0;
  7.     cin >> temp;
  8.     while (temp != 0) {
  9.         tempbefore = temp;
  10.         if (temp < min) {
  11.             min = temp;
  12.         }
  13.         if (temp > max) {
  14.             max = temp;
  15.         }
  16.         count++;
  17.         cin >> temp;
  18.         if (temp < tempbefore) {
  19.             s = max - min;
  20.             min = 1001;
  21.             max = -1;
  22.             if (smax < s) {
  23.                 smax = s;
  24.             }
  25.         }
  26.     }
  27.     cout << "Получено " << count << " чисел" << endl << "Наибольшая высота подъема: " << smax;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement