1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| static void Main(string[] args)
{
int[] nombre = { 1, 2, 3,2 };
Console.WriteLine(Recherche.croissant(nombre, 0));
Console.Read();
}
class Recherche
{
//Fonction qui retourne si les éléments du tableau sont trié
public static bool croissant(int[] arr, int Element)
{
//Si tout le tableau a été vérifié
if(Element + 1 == arr.Lenght)
return true;
//Sinon
else
{
//Si l'élément est plus petit ou égal, on vient vérifié les deux éléments suivants
if (arr[Element] <= arr[Element + 1])
{
return croissant(arr, Element + 1)
}
//Sinon on retourne que le tableau n'est pas bien trié
else
return false;
}
}
} |
Partager