PROGRAM-ID.                      ABC_108_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(19).
    01 x1      PIC S9(3).
    01 y1      PIC S9(3).
    01 x2      PIC S9(3).
    01 y2      PIC S9(3).

    01 dx      PIC S9(3).
    01 dy      PIC S9(3).

    01 ddx     PIC 9(3).
    01 ddy     PIC 9(3).


    01 tx      PIC S9(3).
    01 ty      PIC S9(3).

    01 a1      PIC S9(3).
    01 a2      PIC S9(3).
    01 a3      PIC S9(3).
    01 a4      PIC S9(3).

    01 ans     PIC X(4).
    01 ans1    PIC X(4).
    01 ans2    PIC X(4).
    01 ans3    PIC X(4).
    01 ans4    PIC X(4).
    01 an      PIC X(20).

    01 ZS      PIC -(5)9.
    01 DUMMY   PIC X(1).


PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO x1 y1 x2 y2.

    COMPUTE dx = x2 - x1.
    COMPUTE dy = y2 - y1.
    MOVE dx TO ddx.
    MOVE dy TO ddy.

    IF ZERO <= dx AND ZERO <= dy
        COMPUTE a1 = x2 - ddy
        COMPUTE a2 = y2 + ddx
        COMPUTE a3 = a1 - ddx
        COMPUTE a4 = a2 - ddy
    ELSE
        IF dx < ZERO AND ZERO <= dy
            COMPUTE a1 = x2 - ddy
            COMPUTE a2 = y2 - ddx
            COMPUTE a3 = a1 + ddx
            COMPUTE a4 = a2 - ddy
        ELSE
            IF dx < ZERO AND dy < ZERO
                COMPUTE a1 = x2 + ddy
                COMPUTE a2 = y2 - ddx
                COMPUTE a3 = a1 + ddx
                COMPUTE a4 = a2 + ddy
            ELSE
                COMPUTE a1 = x2 + ddy
                COMPUTE a2 = y2 + ddx
                COMPUTE a3 = a1 - ddx
                COMPUTE a4 = a2 + ddy
            END-IF
        END-IF
    END-IF.

    MOVE a1 TO ZS.
    PERFORM UNANS.
    MOVE ans TO ans1.

    MOVE a2 TO ZS.
    PERFORM UNANS.
    MOVE ans TO ans2.

    MOVE a3 TO ZS.
    PERFORM UNANS.
    MOVE ans TO ans3.

    MOVE a4 TO ZS.
    PERFORM UNANS.
    MOVE ans TO ans4.

    DISPLAY ans1(1:FUNCTION STORED-CHAR-LENGTH(ans1)) ' ' ans2(1:FUNCTION STORED-CHAR-LENGTH(ans2)) ' ' ans3(1:FUNCTION STORED-CHAR-LENGTH(ans3)) ' ' ans4(1:FUNCTION STORED-CHAR-LENGTH(ans4)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
    ZS DELIMITED BY ALL SPACE
    INTO DUMMY ans.
