Advertisement
Guest User

3rd task Arduino

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