Bonjour,
Je dois traduire cela en code, je l'ai fait mais je ne suis pas sûr du résultat. Pourriez-vous m'aider svp? Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 fonction TriInsertion(elements < a0, ..., an−1 >) retourner rien, on trie le tableau pour i = 1 `a n − 1 faire elementCourant = elements[i] j = i - 1 tant que j >= 0 et elementCourant < elements[j] faire elements[j + 1] = elements[j] j = j − 1 fin tant que elements[j + 1] = elementCourant fin pour fin fonction void trier() { int temp; int j = 0; int n = 0; int tab[]; for(int i=0; i<n-1; i++) { temp = tab[i]; j = i-1; while(j>=0 && temp < tab[j]) { tab[j+1] = tab[j]; j=j-1; } tab[j+1]=temp; } }
Partager