그려질 마름모 값을 입력 받는다. (paramater로 입력 받는다.)
마름모의 값은 (크기와 마찬가지라고 보면 된다.. 라인수!!!) 홀수로만 받고, 짝수를 넣으면 에러 텍스트를 뿌린다.
정답코딩은 하단에..
DATA: LV_MOD TYPE I,
LV_POS1 TYPE I,
LV_POS2 TYPE I.
DATA: LV_INDEX TYPE I,
LV_MIDDLE TYPE I,
LV_CENTER TYPE I,
LV_LEFT TYPE I,
LV_RIGHT TYPE I,
LV_L TYPE I,
LV_R TYPE I.
PARAMETERS: P_TIMES TYPE I OBLIGATORY.
LV_MOD = P_TIMES MOD 2.
IF LV_MOD = 0.
MESSAGE S000(OO) DISPLAY LIKE 'W' WITH '홀수만 입력 가능합니다.'.
* STOP.
exit.
*ELSEIF LV_MOD = 1.
* MESSAGE S000(OO) DISPLAY LIKE 'W' WITH '홀수만 입력 가능합니다.'.
* STOP.
ENDIF.
*--------------------------------------------------------------------*
" 마름모 그리기.
LV_CENTER = P_TIMES / 2 + 50.
LV_MIDDLE = P_TIMES / 2 .
LV_LEFT = LV_CENTER.
LV_RIGHT = LV_CENTER .
*LV_R = LV_CENTER - LV_MIDDLE .
*LV_L = LV_CENTER + LV_MIDDLE .
DO P_TIMES TIMES.
LV_INDEX = LV_INDEX + 1.
* LV_LEFT = LV_LEFT - 1.
* LV_RIGHT = LV_RIGHT + 1.
IF LV_INDEX EQ 1 OR LV_INDEX EQ P_TIMES.
WRITE:/LV_CENTER '*'.
ELSEIF LV_INDEX LE LV_MIDDLE.
LV_LEFT = LV_LEFT - 2.
LV_RIGHT = LV_RIGHT + 2.
WRITE:/LV_LEFT '*', AT LV_RIGHT '*'.
ELSEIF LV_INDEX GT LV_MIDDLE.
* LV_R = LV_R + 1.
* LV_L = LV_L - 1.
* WRITE:/LV_R '*', AT LV_L '*'.
LV_LEFT = LV_LEFT + 2.
LV_RIGHT = LV_RIGHT - 2.
WRITE:/LV_LEFT '*', AT LV_RIGHT '*'.
ENDIF.
***
* IF LV_INDEX GT LV_MIDDLE.
*
* WRITE:/LV_RIGHT '*', AT LV_LEFT '*'.
*
* ENDIF.
ENDDO.
SKIP 2.
LV_CENTER = P_TIMES / 2 + 50.
LV_MIDDLE = P_TIMES / 2 .
LV_LEFT = LV_CENTER - LV_MIDDLE.
LV_RIGHT = LV_CENTER + LV_MIDDLE .
DO P_TIMES TIMES.
LV_INDEX = LV_INDEX + 1.
IF LV_INDEX LE LV_MIDDLE.
LV_LEFT = LV_LEFT + 1.
LV_RIGHT = LV_RIGHT - 1.
WRITE:/LV_LEFT '*', AT LV_RIGHT '*'.
ELSEIF LV_INDEX EQ LV_MIDDLE.
WRITE:/LV_CENTER '*'.
ELSEIF LV_INDEX GT LV_MIDDLE.
LV_LEFT = LV_LEFT - 1.
LV_RIGHT = LV_RIGHT + 1.
WRITE:/LV_LEFT '*', AT LV_RIGHT '*'.
ENDIF.
ENDDO.