废话不说,直接上代码:
主要用到PERFORM循环
000010 IDENTIFICATION DIVISION.000011 PROGRAM-ID. STUDY5-103.000020 ENVIRONMENT DIVISION.000030 DATA DIVISION.000031 WORKING-STORAGE SECTION.000040 77 DA1 PIC 99.000050 77 DA2 PIC 99.000051 77 DA3 PIC 99.000052 77 DA4 PIC Z9.000053 77 DA5 PIC Z9.000054 77 DA6 PIC Z9.000055* 01 CFB.000056* 02 000060 PROCEDURE DIVISION.000070 P. PERFORM A000080 VARYING DA1 FROM 1 BY 1 UNTIL DA1 > 9000090 AFTER DA2 FROM 1 BY 1 UNTIL DA2 > DA1.000100 STOP RUN.000110 A. COMPUTE DA3 = DA1 * DA2.000111 MOVE DA3 TO DA4.000112 MOVE DA1 TO DA5.000113 MOVE DA2 TO DA6.000120 IF DA1 = DA2000121 DISPLAY DA6 '*' DA5 '=' DA4 ' ' 000123 ELSE 000124 DISPLAY DA6 '*' DA5 '=' DA4 ' ' WITH NO ADVANCING000130 END-IF. 000140