Advertisement
Steph64

task 1

Dec 13th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;//number of numbers
  9.     cin>>n;
  10.     int arr[100];
  11.     srand(time(0));
  12.     for (int i=0; i<n; i++)
  13.     {
  14.         arr[i]=rand()%30-10;
  15.         cout<<i+1<<'.'<<arr[i]<<endl;
  16.     }
  17.     bool flag=false;
  18.     for (int i=0; i<n-1; i++)
  19.         {
  20.             if (arr[i]*arr[i+1]>0)
  21.                 {
  22.                     flag=true;
  23.                     break;
  24.                 }
  25.         }
  26.  
  27.     if (flag==true) cout<<"yes";
  28.     else cout<<"no";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement