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