63 lines
2.0 KiB
Plaintext
63 lines
2.0 KiB
Plaintext
|
IDENTIFICATION DIVISION.
|
|||
|
PROGRAM-ID. carmag0.
|
|||
|
AUTHOR. OD.
|
|||
|
*----------------------------------------------------------------*
|
|||
|
* PROGRAMME *
|
|||
|
* CREATION TABLEAU IMPAIR *
|
|||
|
*----------------------------------------------------------------*
|
|||
|
|
|||
|
ENVIRONMENT DIVISION.
|
|||
|
|
|||
|
DATA DIVISION.
|
|||
|
WORKING-STORAGE SECTION.
|
|||
|
*--------------------------*
|
|||
|
* DEFINITION DES VARIABLES *
|
|||
|
*--------------------------*
|
|||
|
* Nombre entr<74>e
|
|||
|
77 NBR-DPRT PICTURE 99 VALUE ZERO.
|
|||
|
* Tableau du carr<72> magique
|
|||
|
01 TABLE-CARMAG.
|
|||
|
* - Num<75>ro de ligne
|
|||
|
05 NM-LGN OCCURS 31.
|
|||
|
* - Colonnes de la ligne
|
|||
|
10 CLN OCCURS 31.
|
|||
|
* - - Contenu de chaque colonne : chiffre
|
|||
|
15 CNTN PICTURE 99.
|
|||
|
* Curseur ligne
|
|||
|
77 CRSR-LGN PICTURE 99 VALUE 1.
|
|||
|
77 CRSR-CLN PICTURE 99 VALUE 1.
|
|||
|
* Total d'un calcul
|
|||
|
77 TOTAL PICTURE 99 VALUE ZERO.
|
|||
|
|
|||
|
PROCEDURE DIVISION.
|
|||
|
* Nom du programme
|
|||
|
PROGRAMME SECTION.
|
|||
|
* D<>but du programme (initialisation)
|
|||
|
DEBUT.
|
|||
|
MOVE 3 TO NBR-DPRT.
|
|||
|
* Corps du programme (contenu)
|
|||
|
CORPS.
|
|||
|
DISPLAY "Taille du tableau : " NBR-DPRT.
|
|||
|
PERFORM REMPLI.
|
|||
|
* Fin du programme
|
|||
|
FIN.
|
|||
|
DISPLAY "Carr<72> magique termin<69>.".
|
|||
|
STOP RUN.
|
|||
|
|
|||
|
* Section dédiée aux traitements à effectuer
|
|||
|
TRAITEMENTS SECTION.
|
|||
|
* Remplissage du tableau
|
|||
|
REMPLI.
|
|||
|
COMPUTE TOTAL ROUNDED = NBR-DPRT / 2.
|
|||
|
DISPLAY TOTAL.
|
|||
|
MOVE 1 TO CNTN(1,TOTAL).
|
|||
|
|
|||
|
AFFICHAGE SECTION.
|
|||
|
PARCOURS-TABLEAU.
|
|||
|
PERFORM AFFICHE VARYING CRSR-LGN FROM 1 BY 1 UNTIL CRSR-LGN
|
|||
|
> NBR-DPRT AFTER CRSR-CLN FROM 1 BY 1 UNTIL CRSR-CLN
|
|||
|
> NBR-DPRT.
|
|||
|
AFFICHE.
|
|||
|
DISPLAY "Coordonnées (" CRSR-LGN ", " CRSR-CLN ") : "
|
|||
|
CNTN(CRSR-LGN, CRSR-CLN).
|