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  IDX3                       PIC 9(02).
  03  CNT                        PIC 9(01).
  03  CNT2                       PIC 9(02).
  03  MENSEKI                    PIC 9(08).
  03  MENSEKI-X REDEFINES MENSEKI.
    05  MENSEKI-X-1              PIC X(01) OCCURS 8.
  03  MENSEKI-D01 REDEFINES MENSEKI.
    05  MENSEKIM1                  PIC 9(07).
    05  MENSEKI01                  PIC 9(01).
  03  MENSEKI-D02 REDEFINES MENSEKI.
    05  MENSEKIM2                  PIC 9(06).
    05  MENSEKI02                  PIC 9(02).
  03  MENSEKI-D03 REDEFINES MENSEKI.
    05  MENSEKIM3                  PIC 9(05).
    05  MENSEKI03                  PIC 9(03).
  03  MENSEKI-D04 REDEFINES MENSEKI.
    05  MENSEKIM4                  PIC 9(04).
    05  MENSEKI04                  PIC 9(04).
  03  MENSEKI-D05 REDEFINES MENSEKI.
    05  MENSEKIM5                  PIC 9(03).
    05  MENSEKI05                  PIC 9(05).
  03  MENSEKI-D06 REDEFINES MENSEKI.
    05  MENSEKIM6                  PIC 9(02).
    05  MENSEKI06                  PIC 9(06).
  03  MENSEKI-D07 REDEFINES MENSEKI.
    05  MENSEKIM7                  PIC 9(01).
    05  MENSEKI07                  PIC 9(07).
  03  MENSEKI-D08 REDEFINES MENSEKI.
    05  MENSEKI08                  PIC 9(08).

PROCEDURE DIVISION.

INITIALIZE  WRK-AREA.

ACCEPT  IN-DATA  FROM  SYSIN.

MOVE  1  TO  CNT.
MOVE  0  TO  CNT2.

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  OUTNUM-X
        MOVE  0                 TO  IDX2
      ELSE
        MOVE  OUTNUM-X(1:IDX2)  TO  OUTNUM-BC
        COMPUTE  CNT = CNT + 1
        MOVE  SPACE             TO  OUTNUM-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.



PERFORM  VARYING IDX3 FROM 1 BY 1 UNTIL  IDX3 > 8
  IF  MENSEKI-X-1(IDX3) = ZERO
  THEN
    CONTINUE
  ELSE
    COMPUTE  CNT2 = 9 - IDX3
  END-IF
END-PERFORM.

EVALUATE  CNT2
WHEN 1
  DISPLAY "この三角形の面積は" MENSEKI01 "です。"
WHEN 2
  DISPLAY "この三角形の面積は" MENSEKI02 "です。"
WHEN 3
  DISPLAY "この三角形の面積は" MENSEKI03 "です。"
WHEN 4
  DISPLAY "この三角形の面積は" MENSEKI04 "です。"
WHEN 5
  DISPLAY "この三角形の面積は" MENSEKI05 "です。"
WHEN 6
  DISPLAY "この三角形の面積は" MENSEKI06 "です。"
WHEN  7
  DISPLAY "この三角形の面積は" MENSEKI07 "です。"
WHEN OTHER
  DISPLAY "この三角形の面積は" MENSEKI08 "です。"
END-EVALUATE.

STOP RUN.