Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. using namespace std;
  7.  
  8. int Faktorijel(int n)
  9. {
  10. if (n == 1)
  11. return n;
  12. return n * Faktorijel(n - 1);
  13. }
  14.  
  15. void Unos(int niz[], int indeks, int vel)
  16. {
  17. if (indeks == vel)
  18. return;
  19.  
  20. cout << "Unesite element " << indeks + 1 << ": ";
  21. cin >> niz[indeks];
  22. Unos(niz, indeks + 1, vel);
  23. }
  24.  
  25. void Ispis(int niz[], int indeks, int vel)
  26. {
  27. if (indeks == vel)
  28. {
  29. cout << endl;
  30. return;
  31. }
  32.  
  33. cout << niz[indeks]<< " ";
  34. Ispis(niz, indeks + 1, vel);
  35. }
  36.  
  37. void main()
  38. {
  39. cout << "Faktorijel: " << Faktorijel(4) <<endl;
  40.  
  41. int niz[5];
  42. Unos(niz, 0, 5);
  43. Ispis(niz, 0, 5);
  44.  
  45. system("Pause");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement