daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //#include "pch.h"
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. #define max(a,b) (((a) > (b)) ? (a) : (b))
  8.  
  9. int main()
  10. {
  11.     int prev, cur;
  12.     cin >> prev;
  13.     if (prev)
  14.     {
  15.         cin >> cur;
  16.         int count = 1, count_max = 1;
  17.         int diff_prev = cur - prev;
  18.  
  19.         while (cur)
  20.         {
  21.             int diff_cur = cur - prev;
  22.             if (diff_prev * diff_cur > 0)
  23.             {
  24.                 count++;
  25.             }
  26.             else if (diff_prev * diff_cur == 0)
  27.             {
  28.                 count = 1;
  29.             }
  30.             else
  31.             {
  32.                 count = 2;
  33.             }
  34.             count_max = max(count_max, count);
  35.             diff_prev = diff_cur;
  36.             prev = cur;
  37.             cin >> cur;
  38.         }
  39.         cout << count_max;
  40.     }
  41.     else
  42.     {
  43.         cout << 0;
  44.     }
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top