Advertisement
Guest User

monotonia șirului

a guest
Nov 7th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int i,v[50],n,monoton(1);
  6. int main()
  7. {
  8.     cin>>n;
  9.     for(i=1;i<=n;i++)
  10.        cin>>v[i];
  11.        
  12.     for(i=1;i<=n-2&&monoton;i++)
  13.        if((v[i]-v[i-1])*(v[i+1]-v[i])<=0)  //!!!!!!! nu e mono
  14.            monoton=0;
  15.        if(monoton) if(v[1]-v[0]>0)    cout<<"Sirul strict monoton crescator"<<endl;
  16.                    else                cout<<"Sirul strict monoton descrescator"<<endl;
  17.        else    cout<<"Sirul nu este monoton"<<endl;
  18.  
  19.        return 1337;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement