Дано целое число N (> 0) и непустая строка S. Вывести строку, содержащую символы строки S, между которыми вставлено по N символов «*» (звездочка). В тестах к данной задаче кириллицы нет.
У меня работа с одним массивом. Паскаль. --- uses crt; const N=4; M=6; var a: array [1..n,1..m] of integer; x,y,k,p: integer; begin for x:=1 to n do begin for y:=1 to m do begin a[x,y]:=random(21)-10; write(a[x,y]:4); end; writeln; end; write('k='); readln(k); if k<=m then p:=m-1 else p:=m; for y:=k+1 to m do for x:=1 to n do a[x,y-1]:=a[x,y]; for x:=1 to n do begin for y:=1 to p do write(a[x,y]:4); writeln; end; end.
VAR i, j, k: Integer; a, b: Array [1..5] of Array [1..5] of Integer; BEGIN For i := 1 to 5 do For j := 1 to 5 do Read(a[i][j]);
k := 1; For i := 1 to 5 do If (Odd(i)) then For j := 5 downto 1 do begin b[i][j] := a[((k-1) div 5)+1][((k-1) mod 5)+1]; Inc(k); End Else For j := 1 to 5 do begin b[i][j] := a[((k-1) div 5)+1][((k-1) mod 5)+1]; Inc(k); End;
For i := 1 to 5 do begin For j := 1 to 5 do Write(b[i][j]:2, ' '); Writeln; End; END.
Паскаль.
---
uses crt;
const N=4;
M=6;
var a: array [1..n,1..m] of integer;
x,y,k,p: integer;
begin
for x:=1 to n do begin
for y:=1 to m do begin
a[x,y]:=random(21)-10;
write(a[x,y]:4);
end;
writeln;
end;
write('k='); readln(k);
if k<=m then p:=m-1 else p:=m;
for y:=k+1 to m do
for x:=1 to n do
a[x,y-1]:=a[x,y];
for x:=1 to n do begin
for y:=1 to p do
write(a[x,y]:4);
writeln;
end;
end.
i, j, k: Integer;
a, b: Array [1..5] of Array [1..5] of Integer;
BEGIN
For i := 1 to 5 do
For j := 1 to 5 do Read(a[i][j]);
k := 1;
For i := 1 to 5 do
If (Odd(i)) then
For j := 5 downto 1 do begin
b[i][j] := a[((k-1) div 5)+1][((k-1) mod 5)+1]; Inc(k); End
Else
For j := 1 to 5 do begin
b[i][j] := a[((k-1) div 5)+1][((k-1) mod 5)+1]; Inc(k); End;
For i := 1 to 5 do begin
For j := 1 to 5 do Write(b[i][j]:2, ' ');
Writeln; End;
END.