Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <ctime>
  5. using namespace std;
  6. const int N=10;
  7. int main()
  8. {
  9. int tab[N],i,j;
  10. srand ((unsigned)time(NULL));
  11.  
  12. for(i=0; i<N; i++) tab[i]=rand()%100;
  13. for(i=0; i<N; i++) cout << setw(4) << tab[i];
  14. cout << endl;
  15.  
  16. for(j=0; j<N-1;j++)
  17. for(i=0;i<N-1;i++)
  18. if(tab[i]>tab[i+1])swap(tab[i], tab[i+1]);
  19.  
  20.  
  21. cout<<"po sortowaniu:\n\n";
  22. for(i=0;i<N;i++)cout <<setw(4)<<tab[i];
  23. cout<<endl;
  24. return 0;
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement