Created
April 16, 2015 21:14
-
-
Save developer10/8d532879a0e53467dd69 to your computer and use it in GitHub Desktop.
Parcijala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
/* | |
Napišite program u kojem ćete: | |
Kreirati statički niz od pet (5) cjelobrojnih vrijednosti; | |
Kreirati dinamički niz od dva pokazivača; | |
Inicijalizirati jedan od pokazivača da pokazuje na najmanji element u statičkom nizu; | |
Inicijalizirati drugi pokazivač da pokazuje na najveći element u statičkom nizu; | |
Koristite funkcije. | |
*/ | |
void unos(int [], int v); | |
void iniPokazivace(int [], int **, int); | |
void main() | |
{ | |
const int vel=5; | |
int niz[vel]; | |
int ** PPok = new int *[2]; | |
cout << "Unesite cjelobrojne elemente niza: " << endl; | |
unos(niz, vel); | |
iniPokazivace(niz, PPok, vel); | |
cout << "Ja pokazujem na najmanji element niza a to je: " << *PPok[0] << endl; | |
cout << "Ja pokazujem na najveci element niza a to je: " << *PPok[1] << endl; | |
system("Pause > 0"); | |
} | |
void iniPokazivace(int niz[], int **PPok, int vel) | |
{ | |
int najmanji = niz[0]; | |
int najveci = niz[0]; | |
for (int i = 0; i < vel; i++) | |
{ | |
if(niz[i] < najmanji) | |
najmanji = niz[i]; | |
if(niz[i] > najveci) | |
najveci = niz[i]; | |
} | |
PPok[0] = &najmanji; | |
PPok[1] = &najveci; | |
} | |
void unos(int niz[], int v) | |
{ | |
for (int i = 0; i < v; i++) | |
{ | |
cin >> niz[i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment