fork download
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5.  
  6. const int N=25;
  7. int tab[N];
  8.  
  9. void losuj(int a, int b)
  10. {
  11. srand(time(NULL));
  12. for (int i=0; i<N; i++)
  13. tab[i] = rand()%(b-a+1)+a;
  14.  
  15. }
  16.  
  17. void wypisz()
  18. {
  19. for (int i=0; i<N; i++)
  20. cout << tab[i] << " ";
  21. cout << endl;
  22. }
  23.  
  24.  
  25. void sort_b()
  26. {
  27. for(int i=0; i< N-1; i++)
  28. {
  29. for (int j=0; j<N-1; j++)
  30. {
  31. if (tab[j]<tab[j+1])
  32. swap(tab[j],tab[j+1]);
  33. }
  34. }
  35. }
  36.  
  37. int main() {
  38.  
  39. losuj(-10,10);
  40. wypisz();
  41. sort_b();
  42. wypisz();
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
6 6 -1 -2 1 2 -7 -6 -1 -9 -2 -10 -10 -6 -6 8 1 7 9 -6 6 1 3 -7 -1 
9 8 7 6 6 6 3 2 1 1 1 -1 -1 -1 -2 -2 -6 -6 -6 -6 -7 -7 -9 -10 -10