ABAP arithmetic problem: the number of reported piracy problem.

Title: There have 30 pirate a pirate ship above, respectively, hit an iceberg pirates suddenly 1-30 pirate ship, leaving only one person on board, captain ordered everyone to count cycles, the number of multiples of 7 and 7 people, jump into the sea.

 

Analysis: Nothing good analysis.

Enter the number of pirates, enter the number of deaths, the output pirate death order.

SELECTION-SCREEN BEGIN OF BLOCK b0.
PARAMETERS: p_number   TYPE i OBLIGATORY.
PARAMETERS: p_keyval   TYPE i OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b0.
*
**
TYPES: BEGIN OF person,
         index TYPE i,
         numbr TYPE i,
       END OF person.
DATA :t_person TYPE TABLE OF person.

DATA last_number TYPE i.

t_person = VALUE #( FOR i = 1 UNTIL i > p_number ( index = i ) ).

DO.
  IF lines( t_person ) < 2.EXIT.ENDIF.

  LOOP AT t_person ASSIGNING FIELD-SYMBOL(<s_person>).
    <s_person>-numbr = COND #( WHEN last_number = p_keyval THEN 1 ELSE last_number + 1 ).
    last_number = <s_person>-numbr.
    IF <s_person>-numbr = p_keyval.
      WRITE: / 'index' ,<s_person>-index,'dead! '.
      DELETE t_person.
    ENDIF.
  ENDLOOP.
ENDDO.

READ TABLE t_person ASSIGNING <s_person> INDEX 1.
WRITE :/ 'index', <s_person>-index,'alive '.

 

Guess you like

Origin www.cnblogs.com/yibing-jia/p/11277586.html