/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C/C++.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

// Déclaration de la fonction qui retourne l'indice du minimum
int indice_min(int arr[], int start, int end) {
    // Vérification des indices valides
    if (start < 0 || end < 0 || start > end) {
        printf("Indices invalides.\n");
        return -1; // Renvoie -1 en cas d'erreur
    }

    int min_index = start; // On suppose que le minimum est à l'indice start

    // Parcours du tableau de start à end
    for (int i = start + 1; i <= end; i++) {
        if (arr[i] < arr[min_index]) {
            min_index = i; // Mise à jour de l'indice du minimum
        }
    }

    return min_index; // Retour de l'indice où se trouve la valeur minimale
}

int main() {
    // Exemple de tableau
    int arr[] = {5, 3, 8, 1, 4, 9, 2};
    int start = 1;
    int end = 5;

    // Appel de la fonction
    int min_index = indice_min(arr, start, end);

    // Affichage du résultat
    if (min_index != -1) {
        printf("L'indice du minimum entre %d et %d est: %d\n", start, end, min_index);
    }

    return 0;
}


    