[Java] Rotation de Matrice char
Apaachee
Messages postés
248
Date d'inscription
Statut
Membre
Dernière intervention
-
Pacorabanix Messages postés 3248 Date d'inscription Statut Membre Dernière intervention -
Pacorabanix Messages postés 3248 Date d'inscription Statut Membre Dernière intervention -
Bonjour, j'ai trouvé un algorithme pour "tourner une matrice à 90°" en C, et pour des int.
Je souhaite adapter cela en Java et pour des char, mais je ne sais pas trop comment m'y prendre :s
Je souhaite adapter cela en Java et pour des char, mais je ne sais pas trop comment m'y prendre :s
#include <stdlib.h> #include <stdio.h> #define max 4 int tab[max+1][max+1]; int main() { size_t i,j; for (i=0; i<=max; ++i) for (j=0; j<=max; ++j) tab[j][i] = i*(max+1)+j+1; for (i=0; i<=max; ++i) { for (j=0; j<=max; ++j) printf("%2d ", tab[j][i]); printf ("\n" ); } printf ("\nApres:\n" ); for (j=0; j<max-1; ++j){ for (i=j; i<max-j; ++i){ int temp =tab[i][j] ; tab[i][j] = tab[max-j][i]; tab[max-j][i] = tab[max-i][max-j]; tab[max-i][max-j] =tab[j][max-i]; tab[j][max-i] = temp; } } for (i=0; i<=max; ++i){ for (j=0; j<=max; ++j) printf("%2d ", tab[j][i]); printf ("\n" ); } return 0; }
A voir également:
- [Java] Rotation de Matrice char
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel - Télécharger - Jeux vidéo
- Rotation ecran windows - Guide
- Eclipse java - Télécharger - Langages
- Rotation video - Guide