Tag:Multidimensional Array
-
Perl constant, multidimensional array and variable initialization example code
Example 1: Copy codeThe code is as follows: #!/usr/bin/perl use strict; use warnings; my $test = “asdf”; print “${test}_test2\n”; #constant use constant { AAA => “aaa”, BBB=> “bbb”, MIN_TOTAL => 12, SCORE_PASS => 90, SCORE_RED => 70, }; print AAA; print SCORE_PASS; #two dimesion arrays my @steps = ( […]
-
Lua example of using one-dimensional array and multi-dimensional array
LuaIn the language, there are still differences between arrays and C. Lua’s array subscript counts from 1, while the C language’s array subscript counts from 0. I think this may be designed by the people who designed Lua to conform to people’s thinking habits. Array, that is, a combination arranged in order in memory according […]
-
Linux shell to achieve a multidimensional array of the maximum and minimum
Colleagues sent a shell problem, is to find a multidimensional array of the maximum and minimumSuch as file 99file: 33 55 23 56 99 234 234 545 6546 34 11 43 534 33 75 43 34 76 756 33 343 890 77 667 55 One of my implementations: #! /bin/bash echo “the file is […]
-
Instance code for initialization of Perl constants, multidimensional arrays and variables
Example 1: Copy codeThe code is as follows: #!/usr/bin/perluse strict; use warnings;my $test = “asdf”;print “${test}_test2\n”;#constantuse constant { AAA => “aaa”, BBB=> “bbb”, MIN_TOTAL => 12, SCORE_PASS => 90, SCORE_RED => 70,};print AAA;print SCORE_PASS;#two dimesion arraysmy @steps = ( [“aaa”, “aaavalue”], [“bbb”,”bbbvalue”], [“ccc”,”cccvalue”]);print “\n”;foreach my $i (0 .. $#steps){ print “$steps[$i][0]:$steps[$i][1]\n”;} Code 2: Copy codeThe […]