Carré magique |
Carrés magiques
Remplir un carré magique : c’est disposer les nombres 0 à![Rendered by QuickLaTeX.com p](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-24d437774a144b3203c27d51c5b6c817_l3.png)
![Rendered by QuickLaTeX.com n \times n](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-5c153f893d6518b4fa5cbd8016a20c32_l3.png)
![Rendered by QuickLaTeX.com 5 \times 5](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-f99d692fd05e093b664d02f84a9c52d9_l3.png)
![Rendered by QuickLaTeX.com 7 \times 7](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-18f384a1cda41b90d5841f434f63b530_l3.png)
![Rendered by QuickLaTeX.com n \times n](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-5c153f893d6518b4fa5cbd8016a20c32_l3.png)
![Rendered by QuickLaTeX.com 5 \times 5](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-f99d692fd05e093b664d02f84a9c52d9_l3.png)
14 15 21 2 8 7 13 19 20 1 0 6 12 18 24 23 4 5 11 17 16 22 3 9 10
![Rendered by QuickLaTeX.com b \in \{0, 1, 2\ldots n-1\}](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-bf56fa555cfc41d391c3f6de3babe921_l3.png)
![Rendered by QuickLaTeX.com x_{0} = \frac{n-1}{2} \times n + n -1](https://algotaf.dhenin.fr/wp-content/ql-cache/quicklatex.com-8e04b2a49900b2b68d072ca5e9c125ed_l3.png)
cote = SAISIR () ; b = cote - 1 ; a = (cote - 1) / 2 ; for (ligne = 0 ; ligne < cote ; ligne++) { for (col = 0 ; col < cote ; col++) { IMPRIMER (a * cote) + b ; if (col != (cote - 1)) { a++ ; a = a modulo cote ; b++ ; b = b modulo cote ; } } b-- ; }