Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. { srand(time(0));
  9. int ile, i, j, k, temp;
  10. cout << "\t\t PROGRAM SORTUJACY \n\n\n";
  11. cout << "\t\ Podaj iloma liczbami wypelnic tablice:";
  12. cin >> ile;
  13. int t[ile];
  14.  
  15. for (i=0; i<ile; i++) t[i]=rand()%100;
  16. cout<<"\t Twoja tablica to: ";
  17. for (i=0; i<ile; i++) cout << t[i]<<" ";
  18. cout<<"\n\n";
  19. for (i=0; i<ile-1; i++)
  20. {
  21. for (j=0; j<ile-1; j++)
  22. {
  23. if (t[j]>=t[j+1])
  24. {
  25. temp=t[j];
  26. t[j]=t[j+1];
  27. t[j+1]=temp;
  28. }
  29.  
  30. }
  31. cout << "\t"<< i+1<<")\t";
  32. for (k=0; k<ile; k++) cout <<t[k]<<" ";
  33. cout<<endl;
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement