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