Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Sort_izborom(int* polje, int n) {
- for(int i=n, j; i>0; i--) {
- int maxi = 0;
- for(j=0; j<i; j++)
- if(polje[maxi]>polje[j]) maxi=j;
- int pom = polje[i-1];
- polje[i-1] = polje[maxi];
- polje[maxi] = pom;
- }
- }
- int func_i_ti_broj(int* polje, int n, int i) {
- Sort_izborom(polje, n);
- return polje[i];
- }
- int main() {
- int N, I;
- do {
- cout << "N = ";
- cin >> N;
- } while(N<1);
- do {
- cout << "I = ";
- cin >> I;
- } while(I<0 || I>=N);
- int polje[N];
- for(int i=0; i<N; i++)
- cin >> polje[i];
- int rj = func_i_ti_broj(polje, N, I);
- cout << rj << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement