Tableaux
- ● Un tableau:
- Collection de variables de même type.
- ● Déclaré par:
- Son nom, son type, ses dimensions, ses bornes.
- ● Chaque élément du tableau est représenté par:
- Le nom du tableau
- Un ou plusieurs indices placés chacun entre crochets.
Tableau à une dimension (Vecteur)
| C |
|---|
| #define Nmax <valeur> ou const int Nmax = ≶valeur>; |
| <Type-deonnées> Table [Nmax] |
| C |
|---|
| #define Nmax 10 ou const int Nmax = 10; |
| float T[Nmax]; // premier indice: 0 ou //en cas d'initialisation float T[Nmax] = {1,2, 3, 4, 5, 6, 7, 8, 9}; ou //en cas de qq initialisations float T[Nmax] = {1,,,,0,,,0,,1} |
Tableau à deux dimensions (Matrice)
| C |
|---|
| #define Nmax <valeur> ou const int Nmax = ≶valeur>; |
| <Type-deonnées> Table [Nmax] |
| C |
|---|
| #define Nmax 10 ou const int Nmax = 10; |
| float T[Nmax][Nmax]; // premier indice: 0 ou //en cas d'initialisation float T[Nmax] = {{1,2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9}, ...}; ou //en cas de qq initialisations float T[Nmax][Nmax] = {{1,,,,0,,,0,,1}, {1,,,,0,,,0,,1}} |