Advertisement
arturParchem

sortowaniebomblkowe

May 13th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n=10;
  6. int d[n];
  7. cout<<"Podaj elementy do posortowania: "<<endl;
  8. for(int i=0; i<10;i++)
  9. {
  10.     cout<<"Wypisz element nr: "<<i+1<<endl;
  11.     cin>>d[i];
  12. }
  13. for(int j=0;j<n-1;j++)
  14.     for(int i=0;i<n-1-j;i++)
  15.         if(d[i]>d[i+1])
  16.             swap(d[i], d[i+1]);
  17.  
  18.  
  19. for(int i=0;i<10;i++)
  20. {
  21.     cout<<d[i]<<" ";
  22.  
  23. }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement