fork download
  1. #include <iostream>
  2. #include<ctime>
  3.  
  4.  
  5. using namespace std;
  6. int ile,i,j,zm;
  7. void sortowanie_b (int *tab,int ile)
  8. {
  9.  
  10. do
  11. {
  12. int zm=0;
  13. for(int i=0;i<ile-1;i++)
  14. {
  15. if(tab[i]>tab[i+1])
  16. {
  17. zm=zm+1;
  18. int bufor;
  19. bufor=tab[i+1];
  20. tab[i+1]=tab[i];
  21. tab [i]=bufor;
  22. }
  23. }
  24. }while(zm!=0);
  25. }
  26.  
  27. int main()
  28. {
  29. srand(time(NULL));
  30. cout<<"ile liczb wylosowac? ";
  31. cin>>ile;
  32. cout<<endl;
  33. int *tab;
  34. tab=new int[ile];
  35.  
  36. for(i=0;i<=ile-1;i++)
  37. {
  38. tab[i]=rand()%500+1;
  39. cout<<tab[i]<<endl;
  40. }
  41.  
  42. sortowanie_b(tab,ile);
  43. cout<<"*********\n";
  44. for(i=0;i<=ile-1;i++)
  45. {
  46. cout<<tab[i]<<endl;
  47. }
  48.  
  49. delete [] tab;
  50. return 0;
  51. }
Success #stdin #stdout 0s 3416KB
stdin
6
stdout
ile liczb wylosowac?  
439
341
356
316
227
76
*********
341
356
316
227
76
439