Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. print("sor:\n");
  4. $oszlopok = <STDIN>;
  5. print("oszlop:\n");
  6. $sorok = <STDIN>;
  7.  
  8. chomp($oszlopok);
  9. chomp($sorok);
  10.  
  11. my @matrix;
  12.  
  13. $max = 1;
  14.  
  15. for($i=0; $i<$oszlopok; $i++) {
  16.  
  17. for($j=0; $j<$sorok; $j++) {
  18.  
  19. $input = <STDIN>;
  20. chomp($input);
  21. $matrix[$i][$j] = $input;
  22.  
  23. if( length($input) > $max ) {
  24.  
  25. $max = length($input);
  26.  
  27. }
  28.  
  29. }
  30.  
  31. }
  32.  
  33. for($i=0; $i<$oszlopok; $i++) {
  34.  
  35. for($j=0; $j<$sorok; $j++) {
  36.  
  37. print("$matrix[$i][$j]");
  38. $curlength = length($matrix[$i][$j]);
  39. $diff = $max - $curlength;
  40. for($k=0; $k<=$diff; $k++) {
  41.  
  42. print(" ");
  43.  
  44. }
  45.  
  46. }
  47. print("\n");
  48.  
  49. }
  50.  
  51. if($sorok == $oszlopok) {
  52.  
  53. for($i=0; $i<$oszlopok; $i++) {
  54.  
  55. for($j=0; $j<$sorok; $j++) {
  56.  
  57. if($i==$j) {
  58.  
  59. print("$matrix[$i][$j]");
  60. }
  61.  
  62. for($l=0; $l<length($matrix[$i][$j]); $l++) {
  63.  
  64. print(" ");
  65.  
  66. }
  67.  
  68. $curlength = length($matrix[$i][$j]);
  69. $diff = $max - $curlength;
  70. for($k=0; $k<=$diff; $k++) {
  71.  
  72. print(" ");
  73. }
  74.  
  75. }
  76. print("\n");
  77.  
  78. }
  79.  
  80. }
  81.  
  82. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement