Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*** CODE POUR UN TABLEAU 2D ***/
- void remplir_matrice(int *matrice, int dim_x, int dim_y)
- {
- int x, y;
- for(y = 0; y < dim_y; y++)
- {
- for(x = 0; x < dim_x; x++)
- {
- if(x == y)
- matrice[ y * dim_x + x ] = 1;
- else
- matrice[ y * dim_x + x ] = 0;
- }
- }
- }
- int main()
- {
- int ma_matrice[5][5];
- remplir_matrice(ma_matrice, 5, 5);
- }
- /*** CODE EXEMPLE POUR UN TABLEAU 5D ***/
- int lire_case_tableau(int *matrice, int dim_1, int dim_2, int dim_3, int dim_4, int dim_5)
- {
- int c_1, c_2, c_3, c_4, c_5; // coordonnées de la case à lire, je ne les initialise pas volontairement, c'est à vous de le faire.
- return matrice[ c_5 * dim_4 + c_4 * dim_3 + c_3 * dim_2 + c_2 * dim_1 + c_1 ];
- }
- int main()
- {
- int nombre;
- int ma_matrice[2][3][4][5][6];
- nombre = lire_case_tableau(ma_matrice, 2, 3, 4, 5, 6);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement