상세 컨텐츠

본문 제목

CLASS TEST #4 : Reverse String

ABAP

by Kiroc 2024. 1. 12. 15:26

본문

 

https://exercism.org/tracks/abap/exercises/reverse-string

 

Reverse String in ABAP on Exercism

Can you solve Reverse String in ABAP? Improve your ABAP skills with support from our world-class team of mentors.

exercism.org

 

알고보니 엄청 쉬운 방법이 있었다..ㅎ

 

내가 쓴 답변

CLASS zcl_reverse_string DEFINITION PUBLIC.
  PUBLIC SECTION.
    DATA : GV_LEN TYPE I.
    METHODS reverse_string
      IMPORTING
        input         TYPE string
      RETURNING
        VALUE(result) TYPE string.
ENDCLASS.


CLASS zcl_reverse_string IMPLEMENTATION.
  METHOD reverse_string.
    " Please complete the implementation of the reverse_string method
    GV_LEN = STRLEN( INPUT ) - 1.
    CLEAR RESULT.


    DO GV_LEN + 1 TIMES.
      result = result && input+GV_LEN(1).
      GV_LEN = GV_LEN - 1.
    ENDDO.


  ENDMETHOD.
ENDCLASS.

 

다른 사람의 모범답변

  METHOD reverse_string.
    result = reverse( input ). 
  ENDMETHOD.

관련글 더보기