Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int tab [4];
  8. int i, j;
  9. int pom;
  10. bool przestaw;
  11. cout<<"Podaj 4 elementy " ;
  12. for(i=0;i<=3;i++)
  13. {
  14. cin>>tab[i];
  15. }
  16.  
  17.  
  18. j=3;
  19. do
  20. {
  21. j--;
  22. przestaw=false;
  23. for (i=0; i<=j; i++)
  24. {
  25. if (tab[i]>tab[i+1])
  26. {
  27. pom=tab[i];
  28. tab[i]=tab[i+1];
  29. tab [i+1]=pom;
  30. przestaw=true;
  31. }
  32. }
  33. } while (przestaw);
  34.  
  35. cout<<"Posortowana tablica to";
  36. for(i=0;i<=3;i++)
  37. {
  38. cout<<tab[i]<<", ";
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement