Anonymous user
Array concatenation: Difference between revisions
→{{header|COBOL}}: specified version
Recombinant (talk | contribs) (→{{header|Zig}}: fix, add deinit() where appropriate, use std.mem.concat) |
imported>Acediast (→{{header|COBOL}}: specified version) |
||
Line 1,210:
=={{header|COBOL}}==
{{works with|COBOL 2014}}
<syntaxhighlight lang="cobolfree">IDENTIFICATION DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 table-one.
01 table-two.
77 tally USAGE IS INDEX.
77 show PIC Z(4) USAGE IS DISPLAY.
PROCEDURE DIVISION.
PERFORM
▲ 05 int-field pic 999 occurs 0 to 5 depending on t1.
PERFORM
▲ 05 int-field pic 9(4) occurs 0 to 10 depending on t2.
▲ 77 t1 pic 99.
▲ 77 t2 pic 99.
END-PERFORM
END-PERFORM.
END-PERFORM.
▲ array-concat-main.
DISPLAY FUNCTION TRIM(show) ", " WITH NO ADVANCING
▲ perform concatenate-tables
END-PERFORM
DISPLAY FUNCTION TRIM(show).
▲ initialize-tables.
▲ perform varying tally from 1 by 1 until tally > t1
▲ compute int-field of table-one(tally) = tally * 3
▲ perform varying tally from 1 by 1 until tally > t2
▲ compute int-field of table-two(tally) = tally * 6
▲ .
▲ concatenate-tables.
▲ perform varying tally from 1 by 1 until tally > t1
▲ add 1 to t2
▲ move int-field of table-one(tally)
▲ to int-field of table-two(t2)
▲ .
▲ display-result.
▲ perform varying tally from 1 by 1 until tally = t2
▲ move int-field of table-two(tally) to show
▲ move int-field of table-two(tally) to show
▲ .
▲ end program array-concat.</syntaxhighlight>
{{out}}
<pre>
6, 12, 18, 3, 6, 9, 12
</pre>
|