Advertisement
Guest User

3rd task Arduino

a guest
Nov 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main(){
  7.     int n, time;
  8.     int curr;
  9.     vector <int> data;
  10.     cin >> n;
  11.     for (int i=0; i<n; i++) {
  12.         cin >> curr;
  13.         data.push_back(curr);
  14.     }
  15.     for (int i = data.size() - 1; i>=0; i--) {
  16.         if (i == 0) {
  17.             if (time >= 3) cout << "True";
  18.             else cout << "False";
  19.         }
  20.         else if (abs(data[i] - data[i-1]) <= 3) time++;
  21.         else {
  22.             if (time >= 3) cout << "True";
  23.             else cout << "False";
  24.             break;
  25.         }
  26.         //else if (data[i] < data[i-1]) {
  27.         //    if (time >= 3) cout << "True";
  28.         //    else cout << "False";
  29.         //    break;
  30.         //}
  31.         //else if (data[i] > data[i-1]) {
  32.         //    cout << "False";
  33.         //    break;
  34.         //}
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement