fork download
  1. #include <iostream>
  2. #include <clocale>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. setlocale(LC_ALL, "ru");
  9. srand(time(NULL));
  10.  
  11. const int MAX_LENGTH = 10;
  12. int array[MAX_LENGTH];
  13.  
  14. for (int i = 0; i < MAX_LENGTH; i++)
  15. {
  16. array[i] = rand() % 19;
  17. cout << array[i] << " ";
  18. }
  19. cout << endl;
  20.  
  21. int idx_maxV = 0;
  22. for (int i = 1; i < MAX_LENGTH; ++i)
  23. {
  24. if (array[i] > array[idx_maxV])
  25. idx_maxV = i;
  26. }
  27.  
  28. int idx_minV = 0;
  29. for (int i = 1; i < MAX_LENGTH; ++i)
  30. {
  31. if (array[i] < array[idx_minV])
  32. idx_minV = i;
  33. }
  34.  
  35. cout << "maxV = " << array[idx_maxV] << "\nminV = " << array[idx_minV] << endl;
  36.  
  37. int length = MAX_LENGTH;
  38.  
  39. for (int i = idx_maxV+1; i < length; ++i)
  40. {
  41. array[i-1] = array[i];
  42. }
  43. --length;
  44.  
  45. if (idx_minV > idx_maxV)
  46. --idx_minV;
  47.  
  48. for (int i = idx_minV+1; i < length; ++i)
  49. {
  50. array[i-1] = array[i];
  51. }
  52. --length;
  53.  
  54. for (int i = 0; i < length; i++)
  55. {
  56. cout << array[i] << " ";
  57. }
  58. cout << endl;
  59. }
Success #stdin #stdout 0.01s 5396KB
stdin
Standard input is empty
stdout
12  9  17  9  9  9  15  18  9  6  
maxV = 18
minV = 6
12  9  17  9  9  9  15  9