LoginSignup
1
0

More than 3 years have passed since last update.

Gnu-COBOL 配列

Last updated at Posted at 2020-09-02

配列

  • 同じ種類のデータをまとめて管理する
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
  WORKING-STORAGE SECTION.
    01 COLORS.
     03 ONE-COLOR OCCURS 3 PIC X(10). *> 「OCCURS」 -> 要素数を指定する
PROCEDURE DIVISION.
  MAIN SECTION.
    MOVE "RED" TO ONE-COLOR(1).
    MOVE "BLUE" TO ONE-COLOR(2).
    MOVE "YELLOW" TO ONE-COLOR(3).
    DISPLAY COLORS.
    DISPLAY ONE-COLOR(2).
    STOP RUN.

コンパイル/実行

コンパイル

cobc -x --free hello.cob

実行

USER-no-MacBook-Air:COBOL user$ ./hello
RED       BLUE      YELLOW    
BLUE 
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0