Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include<windows.h>
  3. using namespace std;
  4. int rekurzija(int x)
  5. {
  6.     if (x == 100)
  7.         return 100;
  8.     if (x < 100)
  9.     {
  10.         if (x % 2 == 0)
  11.             return x + rekurzija(x + 2);
  12.         else
  13.         {
  14.             x++;
  15.             return x + rekurzija(x + 2);
  16.         }      
  17.     }
  18.     else
  19.         {
  20.             if (x % 2 == 0)
  21.                 return x + rekurzija(x -2);
  22.             else
  23.             {
  24.                 x--;
  25.                 return x + rekurzija(x - 2);
  26.             }
  27.         }
  28. }
  29. void main()
  30. {
  31.     int x;
  32.     do
  33.     {
  34.         cin >> x;
  35.     } while (x == 100);
  36.     int y = rekurzija(x);
  37.     cout <<y<< endl;
  38.     system("PAUSE");
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement