Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- //https://www.softwaretestinghelp.com/bubble-sort/
- int zmienne;
- cout<<"Wprowadz ilosc zmiennych: ";
- cin>>zmienne;
- float array[zmienne];
- cout<<"Wprowadzaj kolejne elementy: "<<endl;
- for(int i=0; i<zmienne; i++)
- {
- cin>>array[i];
- }
- for(int przejscia=0; przejscia<zmienne; przejscia++)
- {
- for(int passes=0; passes<zmienne-1; passes++)
- {
- if(array[passes]>array[passes+1])
- {
- swap(array[passes],array[passes+1]);
- };
- }
- }
- cout<<endl;
- for(int i=0; i<zmienne; i++)
- {
- cout<<array[i]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement