The array is cyclically shifted left by 1 element. The task is to shift the array until the minimum value becomes the first (zero value).

void zmischennya(int masuv[], int n, int min, ...) { int j, temp, temp1, k; temp = masuv[0]; //запоминаем первый елемент printf("\n Zmischennuy masuv na 1:\n"); for (j = 0; j < n; j++) { masuv[j] = masuv[j + 1]; //сдвигаем на 1 елемент masuv[n] = temp; printf("\t %i", masuv[j]); } printf("\n Zmischenuy masuv min=1:\n"); temp1 = masuv[0]; for (j = 1; j < n; j++) //цыкл смещения пока мин == масив[0] { if (masuv[0] != min) // проверка не стоит ли мин первым, если нет то: { // сдвигаем пока не выполниться условие masuv[j] = masuv[j + 1]; masuv[n] = temp1; printf("\t %i", masuv[j]); } else // если да то просто выводим значения printf("\t %i", masuv[j]); } getch(); } 

But only the left shift works, and the shift does not work until the condition is met. Why? Help me please.

  • one
    Find the index of the minimum element and shift the array by this value. By the way, they wrote to you, wrote in the previous question, how to make a cyclical shift, but the program still has an error. First of all, think about masuv [n] = temp; How many elements do you have in a masuv? - avp
  • Note: you need to return the value stored in a temporary variable only once. And it should get into the element with max. index - but this is the index n-1 , not n ! - VladD 2:46
  • one
    1. It’s necessary to search for a minimum, but you are driven into the parameters for an easy life. 2. Give up the habit of writing texts on Volapuk, such as masuv. A disgusting impression leads to the reader and to the teacher, too, will act badly. - BuilderC

0