Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. //algorytm sprawdzający czy ciąg jest rosnący
  2. #include<iostream>
  3.  
  4. using namespace std;
  5. const int MAX=10;
  6. bool rosnacy (int T[],int n){
  7. for(int i=0;i<n-1;i++)
  8. if(T[i]>=T[i+1]) return false;
  9. return true;
  10.  
  11. }
  12.  
  13.  
  14.  
  15.  
  16. int main(){
  17. int T[MAX],n;
  18. cout<<"Podaj liczbe elementow tablicy: ";
  19. cin>>n;
  20. cout<<"Podaj element tablicy: "<<endl;
  21. for(int i=0;i<n;i++){
  22.  
  23. cout<<"T["<<i<<"]=";
  24. cin>>T[i];
  25.  
  26.  
  27. }
  28. if (rosnacy (T,n)) cout<<"Ciag jest rosnacy"<<endl;
  29. else cout<<"ciag nie jest rosnacy"<<endl;
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement