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