输入:0123456789
输出:9876543210
严格要求10位,cobol必须严格要求位数。
代码如下:
000010 IDENTIFICATION DIVISION.000020 PROGRAM-ID. STUDY6-103.000030 ENVIRONMENT DIVISION.000040 DATA DIVISION.000050 WORKING-STORAGE SECTION.000060 01 W-DATA PIC X(10).000070 01 W-DATA-1 REDEFINESW-DATA.000080 03 WA PIC X.000090 03 WB PIC X.000100 03 WC PIC X.000110 03 WD PIC X.000120 03 WE PIC X.000130 03 WF PIC X.000140 03 WG PIC X.000150 03 WH PIC X.000160 03 WI PIC X.000170 03 WJ PIC X.000180 01 W-DATA-2.000190 03 WJ PIC X.000200 03 WI PIC X.000210 03 WH PIC X.000220 03 WG PIC X.000230 03 WF PIC X.000240 03 WE PIC X.000250 03 WD PIC X.000260 03 WC PIC X.000270 03 WB PIC X.000280 03 WA PIC X.000290 PROCEDURE DIVISION.000300 ACCEPT W-DATA.000310 MOVE CORR W-DATA-1 TO W-DATA-2.000320 DISPLAY W-DATA-2.000330 STOP RUN.000340
此次主要联系CORR的用法,如果不加的话会前后一致的赋值,输出结果和输入一样,加上以后会按照相同名称赋值。