Refine .gitignore some more.
[Algorithmic_C.git] / TP2 / exo1 / exo1.c
1 #include <stdio.h>
2
3 void permuter(int T[], int i1, int i2) {
4 int tmp = T[i1];
5 T[i1] = T[i2];
6 T[i2] = tmp;
7 }
8
9 int i_min(int T[], int n, int d) {
10 int min = d;
11 for (int i = d+1; i < n; i++) {
12 if (T[i] < T[min]) {
13 min = i;
14 }
15 }
16 return min;
17 }
18
19 void SelecEch(int T[], int n) {
20 int imin, d = 0;
21 while (d < n-1) {
22 imin = i_min(T, n, d);
23 permuter(T, d, imin);
24 d++;
25 }
26 }
27
28 void AfficheTab(int T[], int n) {
29 for (int i = 0; i < n; i++) {
30 printf("T[%d]=%d\n", i, T[i]);
31 }
32 }
33
34 int main() {
35 int T[6] = {2, 5, 3, 1, 4, 6};
36
37 AfficheTab(T, 6);
38
39 SelecEch(T, 6);
40
41 AfficheTab(T, 6);
42
43 return 0;
44 }