Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int ilosc;
  4.  
  5.  
  6. void sprawdzanie(float *tab, int n, int r){
  7.         if(n!=ilosc-2){
  8.             if(tab[n+1]>tab[n]){
  9.              if(r!=1)
  10.             cout << "Funkcja niemotoniczna";
  11.             else {
  12.                 sprawdzanie(tab, n+1, 1);
  13.                 if(n==ilosc-2)
  14.                 cout << "Funkcja rosnaca";
  15.                 }
  16.             }
  17.        
  18.         else if (tab[n+1]<tab[n]){
  19.         if (r!=2){
  20.             cout << "Funkcja niemotoniczna";
  21.             }
  22.             else
  23.             {
  24.                 sprawdzanie(tab, n+1, 2);
  25.                 if(n==ilosc-2){
  26.                     cout << "Funkcja malejaca";
  27.                 }
  28.             }
  29.         }
  30.         else if (tab[n]==tab[n+1]){
  31.             if(r!=3){
  32.                 cout << "Funkcja niemotoniczna";
  33.             }
  34.             else {
  35.                 sprawdzanie(tab, n+1, 3);
  36.                 if(n==ilosc-2){
  37.                     cout << "Funkcja stała";
  38.                 }
  39.             }
  40.         }
  41.     }
  42. }
  43.  
  44. void spr(float *tab){
  45.     if (tab[1]>tab[0]){
  46.         sprawdzanie(tab, 0, 1);
  47.     }
  48.     else if (tab[1]<tab[0]){
  49.         sprawdzanie(tab, 0, 2);
  50.     }
  51.     else sprawdzanie(tab, 0, 3);
  52. }
  53.  
  54. int main(){
  55.     cout << "Podaj ilosc: ";
  56.     cin>>ilosc;
  57.     float tab[ilosc];
  58.     for(int i=0; i<=ilosc-1; i++){
  59.     cin>>tab[i];
  60.     }
  61.    
  62.     spr(tab);
  63.     /*for(int i=0; i<=ilosc-1; i++){
  64.     cout << tab[i];
  65. }*/
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement