fork(7) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void sortowanie(int uczestnicy, int *tablica)
  6. {
  7. for (int i = 0; i < uczestnicy; i++)
  8. {
  9.  
  10. for (int j = 1; j < uczestnicy - i; j++)
  11. {
  12. if (tablica[j - 1] < tablica[j])
  13.  
  14. swap(tablica[j - 1], tablica[j]);
  15. }
  16. }
  17. }
  18.  
  19.  
  20.  
  21. int main()
  22. {
  23. int d, n, *tab = nullptr, x = 0;
  24.  
  25. cin >> d;
  26.  
  27. for (int i = 0; i < d; i++)
  28. {
  29. cin >> n;
  30.  
  31. tab = new int[n];
  32.  
  33. for (int j = 0; j < n; j++)
  34. {
  35. cin >> tab[j];
  36. }
  37.  
  38. sortowanie(n, tab);
  39.  
  40.  
  41.  
  42. cout << tab[x] << " ";
  43.  
  44. while (true)
  45. {
  46. if (tab[x] == tab[x + 1])
  47. {
  48. cout << tab[x + 1] << " ";
  49. x++;
  50. }
  51.  
  52. else
  53. {
  54. break;
  55. }
  56. }
  57.  
  58. for (int j = n - 1; j > x; j--)
  59. {
  60.  
  61. cout << tab[j] << " ";
  62.  
  63. }
  64. cout << endl;
  65. x = 0;
  66. }
  67.  
  68. delete[] tab;
  69.  
  70. system("pause");
  71.  
  72. return 0;
  73. }
Success #stdin #stdout #stderr 0s 3416KB
stdin
1 5 4 8 1 22 0
stdout
22 8 4 1 0 
stderr
sh: 1: pause: not found