Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int tab [4];
- int i, j;
- int pom;
- bool przestaw;
- cout<<"Podaj 4 elementy " ;
- for(i=0;i<=3;i++)
- {
- cin>>tab[i];
- }
- j=3;
- do
- {
- j--;
- przestaw=false;
- for (i=0; i<=j; i++)
- {
- if (tab[i]>tab[i+1])
- {
- pom=tab[i];
- tab[i]=tab[i+1];
- tab [i+1]=pom;
- przestaw=true;
- }
- }
- } while (przestaw);
- cout<<"Posortowana tablica to";
- for(i=0;i<=3;i++)
- {
- cout<<tab[i]<<", ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement