Correction Tri selection

Run Settings
LanguageC#
Language Version
Run Command
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exercice_Tri { class MainClass { public static void Main(string[] args) { //liste d'un groupe d'élève int[] tab = { 0, 12, 8, 3, 1 }; //Tri ce tableau à l'aide AfficherTab(TriParSelection(tab)); } static void AfficherTab(int [] tab) { for (int i = 0; i < tab.Length; i++) { Console.WriteLine(tab[i]); } } static int Pos_min(int[] tab, int ind) { // on considère que le plus élèment est le premier est donc que sa position dans le tableau est 0 for (int i = ind; i < tab.Length; i++) { if (tab[i] < tab[ind]) { ind = i; } } return ind; } static int [] Echanger(int [] tab, int x, int y) { //Pour échanger deux élèments, on doit stocker la valeur du premier dans une variable temporaire int temp = tab[x]; tab[x] = tab[y]; tab[y] = temp; return tab; } static int [] TriParSelection(int[] tab) { //**code ici la solution pour trier en t'aidant des méthodes for (int i = 0; i < tab.Length; i++) { tab = Echanger(tab, i, Pos_min(tab,i)); } return tab; } } }
Editor Settings
Theme
Key bindings
Full width
Lines