ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1506. Columns of Numbers

Why WA #10 ? Pascal
Posted by Denuha 1 Mar 2014 16:56
var
     mas: array [1..100] of integer;
     mas2: array [1..100, 1..100] of integer;
     n, k, str, f, i, j, kol: integer;

begin
     readln(n, k);
        {for i:=1 to  n do read mas[i];}
        {Считаем кол-во строк}
     if n mod k <> 0 then str := (n div k) + 1 else str := n div k;
        {Считаем "полную" матрицу}
     kol := k * str;
     for i := 1 to n do read(mas[i]);
        {Заполняем "-1" будущие пустые места}
     for i := n + 1 to kol do mas[i] := -1;
     f := 1;
     for i := 1 to k do
          for j := 1 to str do
          begin
               mas2[j, i] := mas[f];
               inc(f);
          end;
     for i := 1 to str do
     begin
          for j := 1 to k do
               if mas2[i, j] <> -1 then write(mas2[i, j]:4) else continue;
          writeln;
     end;
end.