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 * polje = new float[N];
- for(int i = 0; i < N; i++) {
- cout << "Broj: ";
- cin >> polje[i];
- }
- bool found = true;
- while(found) {
- found = false;
- for(int i = 0; i < N-1; i++) {
- if(polje[i] > polje[i+1]) {
- swap(polje[i], polje[i+1]);
- found = true;
- }
- }
- }
- for(int i = 0; i < N; i++)
- cout << polje[i] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment