Première partie (ne donne pas la bonne réponse
This commit is contained in:
parent
3f75383e35
commit
dc9887ebd9
1 changed files with 70 additions and 11 deletions
|
@ -8,6 +8,7 @@
|
||||||
ORGANIZATION LINE SEQUENTIAL.
|
ORGANIZATION LINE SEQUENTIAL.
|
||||||
|
|
||||||
DATA DIVISION.
|
DATA DIVISION.
|
||||||
|
|
||||||
FILE SECTION.
|
FILE SECTION.
|
||||||
FD FILE1.
|
FD FILE1.
|
||||||
01 INPUT-FILE.
|
01 INPUT-FILE.
|
||||||
|
@ -15,25 +16,83 @@
|
||||||
|
|
||||||
WORKING-STORAGE SECTION.
|
WORKING-STORAGE SECTION.
|
||||||
01 MY-FILE.
|
01 MY-FILE.
|
||||||
02 STR PIC A(17).
|
02 MY-STR PIC A(17).
|
||||||
01 WS-STATUS PIC X VALUE 'N'.
|
01 FILE-STATUS PIC X VALUE 'N'.
|
||||||
88 EOF VALUE 'Y'.
|
88 EOF VALUE 'Y'.
|
||||||
|
77 NB-NICE PIC 9(4) VALUE 0.
|
||||||
|
|
||||||
PROCEDURE DIVISION.
|
PROCEDURE DIVISION.
|
||||||
main.
|
main.
|
||||||
OPEN INPUT FILE1.
|
OPEN INPUT FILE1.
|
||||||
PERFORM UNTIL EOF
|
PERFORM UNTIL EOF
|
||||||
READ FILE1 RECORD INTO MY-FILE
|
READ FILE1 RECORD INTO MY-FILE
|
||||||
AT END MOVE 'Y' TO WS-STATUS
|
AT END MOVE 'Y' TO FILE-STATUS
|
||||||
NOT AT END DISPLAY MY-FILE
|
NOT AT END CALL "parse-str" USING
|
||||||
|
BY CONTENT MY-STR,
|
||||||
|
BY REFERENCE NB-NICE
|
||||||
|
END-CALL
|
||||||
END-READ
|
END-READ
|
||||||
END-PERFORM.
|
END-PERFORM.
|
||||||
|
DISPLAY "Nombre de bonnes chaines : " NB-NICE.
|
||||||
CLOSE FILE1.
|
CLOSE FILE1.
|
||||||
STOP RUN.
|
STOP RUN.
|
||||||
|
|
||||||
END PROGRAM jour-cinq-prem-part.
|
END PROGRAM jour-cinq-prem-part.
|
||||||
|
|
||||||
*deuxième étape, lire car par car
|
******************************************************************
|
||||||
*troisième étape, check si voyelle
|
|
||||||
*retenir lettre act et pred pour check mot interdit
|
IDENTIFICATION DIVISION.
|
||||||
*retenir lettre jusqu’à double
|
PROGRAM-ID. parse-str.
|
||||||
|
|
||||||
|
DATA DIVISION.
|
||||||
|
WORKING-STORAGE SECTION.
|
||||||
|
77 CHAR PIC A.
|
||||||
|
88 VOY VALUE 'a','e','i','o','u','y'.
|
||||||
|
77 I PIC 99.
|
||||||
|
88 END-P VALUE 17.
|
||||||
|
77 NB-VOY PIC 99.
|
||||||
|
77 PRED PIC A.
|
||||||
|
77 TMP PIC AA.
|
||||||
|
88 BAD VALUE 'ab', 'cd', 'pq', 'xy'.
|
||||||
|
77 DOUBLE PIC X.
|
||||||
|
|
||||||
|
LINKAGE SECTION.
|
||||||
|
77 STR PIC A(17).
|
||||||
|
77 NB PIC 9(4).
|
||||||
|
|
||||||
|
PROCEDURE DIVISION USING STR, NB.
|
||||||
|
parse.
|
||||||
|
MOVE 0 TO NB-VOY.
|
||||||
|
MOVE 'N' TO DOUBLE.
|
||||||
|
d DISPLAY STR.
|
||||||
|
d DISPLAY "=================".
|
||||||
|
PERFORM VARYING I FROM 1 BY 1 UNTIL END-P
|
||||||
|
MOVE STR(I:1) TO CHAR
|
||||||
|
d DISPLAY "ACT. CHAR : " CHAR
|
||||||
|
d DISPLAY "ACT. PRED : " PRED
|
||||||
|
d DISPLAY "I : " I
|
||||||
|
IF VOY
|
||||||
|
THEN ADD 1 TO NB-VOY
|
||||||
|
END-IF
|
||||||
|
IF I >= 2
|
||||||
|
THEN
|
||||||
|
STRING PRED CHAR INTO TMP
|
||||||
|
d DISPLAY "TMP STR : " TMP
|
||||||
|
IF BAD
|
||||||
|
THEN
|
||||||
|
EXIT PERFORM
|
||||||
|
END-IF
|
||||||
|
IF PRED = CHAR
|
||||||
|
THEN
|
||||||
|
MOVE 'Y' TO DOUBLE
|
||||||
|
END-IF
|
||||||
|
d DISPLAY "DOUBLE : " DOUBLE
|
||||||
|
END-IF
|
||||||
|
MOVE CHAR TO PRED
|
||||||
|
END-PERFORM.
|
||||||
|
IF NOT BAD AND NB-VOY >= 3 AND DOUBLE = 'Y'
|
||||||
|
THEN
|
||||||
|
ADD 1 TO NB
|
||||||
|
END-IF.
|
||||||
|
|
||||||
|
END PROGRAM parse-str.
|
||||||
|
|
Loading…
Reference in a new issue