Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void unosREK (int niz[], int max)
- {
- if (max <= 0) cin >> niz[0];
- else
- {
- cin >> niz[max];
- unosREK(niz, max - 1);
- }
- }
- void ispisREK (int niz[], int max)
- {
- if (max <= 0) cout << niz[0];
- else
- {
- cout << niz[max] << "\t";
- ispisREK(niz, max - 1);
- }
- cout << endl;
- }
- int sumaREK (int niz[], int max)
- {
- int sum = 0;
- if (max <= 0) sum += niz[0];
- else
- {
- return sum += niz[max] + sumaREK(niz, max - 1);
- }
- }
- int main()
- {
- const int max = 7;
- int niz[max];
- cout << "******** UNOS ELEMENATA ******** " << endl << endl;
- unosREK(niz, max-1);
- cout << "******** ISPIS ELEMENATA ******** " << endl << endl;
- ispisREK(niz, max-1);
- cout << "******** SUMA ELEMENATA ******** " << endl << endl;
- cout << sumaREK(niz, max-1);
- system("pause > null");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement