       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRIANGLE.
       DATA                             DIVISION.
       WORKING-STORAGE                  SECTION.
       01 WRK-AREA.
         03  IN-DATA.
           05  IN-DATA-1                PIC X(01) OCCURS 20.
         03  OUTNUM-X.
           05  OUTNUM-X-1               PIC X(01) OCCURS 6.
         03  OUTNUM-AB                  PIC 9(06).
         03  OUTNUM-BC                  PIC 9(06).
         03  IDX1                       PIC 9(02).
         03  IDX2                       PIC 9(02).
         03  CNT                        PIC 9(01).
         03  MENSEKI                    PIC 9(10).

       PROCEDURE DIVISION.
       
       INITIALIZE  WRK-AREA.
       
       ACCEPT  IN-DATA  FROM  SYSIN.
       
       MOVE  1  TO  CNT.

       PERFORM  VARYING IDX1 FROM 1 BY 1 UNTIL  CNT > 2
       
         IF IN-DATA-1(IDX1) = SPACE
         THEN
           IF  IDX2 = 0
           THEN
             CONTINUE
           ELSE
             IF  CNT = 1
             THEN
               MOVE  OUTNUM-X(1:IDX2)  TO  OUTNUM-AB
               COMPUTE  CNT = CNT + 1
               MOVE  SPACE             TO  OUNNUM-X
               MOVE  0                 TO  IDX2
             ELSE
               MOVE  OUTNUM-X(1:IDX2)  TO  OUTNUM-BC
               COMPUTE  CNT = CNT + 1
               MOVE  SPACE             TO  OUNNUM-X
               MOVE  0                 TO  IDX2
             END-IF
           END-IF
         ELSE
           COMPUTE  IDX2 = IDX2 + 1
           MOVE  IN-DATA-1(IDX1)     TO  OUTNUM-X-1(IDX2)
         END-IF
       
       END-PERFORM.

       COMPUTE MENSEKI = OUTNUM-AB * OUTNUM-BC / 2.
       DISPLAY 'この三角形の面積は ' MENSEKI ' です。'.

       STOP RUN.

