Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void unos(int niz[], int vel)
- {
- for (int i = 0; i < vel; i++)
- {
- cin >> niz[i];
- }
- }
- int min(int a, int b)
- {
- if (a<b)
- {
- return a;
- }
- return b;
- }
- void inicijalizacija(int niz1[], int niz2[], int niz3[], int vel)
- {
- for (int i = 0; i < vel; i++)
- {
- niz3[i] = min(niz1[i], niz2[i]);
- }
- }
- bool opadajuci(int niz[], int vel)
- {
- for (int i = 0; i < vel; i++)
- {
- if (niz[i] < niz[i + 1])
- {
- return false;
- }
- }
- return true;
- }
- void ispis(int niz[], int vel)
- {
- for (int i = 0; i < vel; i++)
- {
- cout << niz[i] << " ";
- }
- cout << endl;
- }
- void main()
- {
- const int vel = 5;
- int niz1[vel];
- int niz2[vel];
- int niz3[vel];
- unos(niz1, vel);
- unos(niz2, vel);
- inicijalizacija(niz1, niz2, niz3, vel);
- ispis(niz1, vel);
- ispis(niz2, vel);
- ispis(niz3, vel);
- int izbor;
- cout << "Izaberite niz za koji zelite provjeriti da li su mu elementi u opadajucem poretku:" << endl;
- cout << "Izaberite: 1, 2 ili 3" << endl;
- cin >> izbor;
- if (izbor == 1)
- {
- if (opadajuci(niz1, vel) == true)
- {
- cout << "Niz je opadajuci!" << endl;
- }
- else
- cout << "Niz nije opadajuci!" << endl;
- }
- if (izbor == 2)
- {
- if (opadajuci(niz2, vel) == true)
- {
- cout << "Niz je opadajuci!" << endl;
- }
- else
- cout << "Niz nije opadajuci!" << endl;
- }
- if (izbor == 3)
- {
- if (opadajuci(niz3, vel) == true)
- {
- cout << "Niz je opadajuci!" << endl;
- }
- else
- cout << "Niz nije opadajuci!" << endl;
- }
- system("pause>0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement