Advertisement
marius7122

Untitled

Jul 9th, 2019
159
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.  
  3. using namespace std;
  4.  
  5. int v[100], n, i;
  6.  
  7. int main()
  8. {
  9.     cout<<"n = "; cin>>n;
  10.     for(i=0;i<n;i++)
  11.     {
  12.         cout<<"v["<<i<<"] = "; cin>>v[i];
  13.     }
  14.  
  15.     int cresc = 1, desc = 1;
  16.     for(i=1;i<n;i++)
  17.     {
  18.         if(v[i-1] >= v[i])
  19.             cresc = 0;
  20.  
  21.         if(v[i-1] <= v[i])
  22.             desc = 0;
  23.     }
  24.  
  25.     if(cresc)
  26.         cout<<"Sirul este crescator"<<endl;
  27.     else if(desc)
  28.         cout<<"Sirul este descrescator"<<endl;
  29.     else
  30.         cout<<"Sirul nu este ordonat"<<endl;
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement