Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- print("sor:\n");
- $oszlopok = <STDIN>;
- print("oszlop:\n");
- $sorok = <STDIN>;
- chomp($oszlopok);
- chomp($sorok);
- my @matrix;
- $max = 1;
- for($i=0; $i<$oszlopok; $i++) {
- for($j=0; $j<$sorok; $j++) {
- $input = <STDIN>;
- chomp($input);
- $matrix[$i][$j] = $input;
- if( length($input) > $max ) {
- $max = length($input);
- }
- }
- }
- for($i=0; $i<$oszlopok; $i++) {
- for($j=0; $j<$sorok; $j++) {
- print("$matrix[$i][$j]");
- $curlength = length($matrix[$i][$j]);
- $diff = $max - $curlength;
- for($k=0; $k<=$diff; $k++) {
- print(" ");
- }
- }
- print("\n");
- }
- if($sorok == $oszlopok) {
- for($i=0; $i<$oszlopok; $i++) {
- for($j=0; $j<$sorok; $j++) {
- if($i==$j) {
- print("$matrix[$i][$j]");
- }
- for($l=0; $l<length($matrix[$i][$j]); $l++) {
- print(" ");
- }
- $curlength = length($matrix[$i][$j]);
- $diff = $max - $curlength;
- for($k=0; $k<=$diff; $k++) {
- print(" ");
- }
- }
- print("\n");
- }
- }
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement