daily pastebin goal
79%
SHARE
TWEET

task 1

Steph64 Dec 13th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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