Var ar:array[1..s] of integer; n,m,i:integer; begin writeln('N'); readln(n); writeln('M'); readln(m); writeln('Array:'); for i:=1 to s do readln(ar[i]); writeln('First array:'); for i:=1 to s do begin write(ar[i]:4); if ar[i] div n<>0 then ar[i]:=ar[i]+m; end; writeln; writeln('Final array:'); for i:=1 to s do write(ar[i]:4); end.
Пример ввода: 3 3 1 2 3 4 5 Пример вывода: First array: 1 2 3 4 5 Final array: 1 2 6 7 8
Var ma:array[1..n,1..n] of integer; i,j:integer; begin writeln('Matrix reading...'); for i:=1 to n do begin writeln; for j:=1 to n do readln(ma[i,j]); end; writeln('First matrix:'); for i:=1 to n do begin writeln; for j:=1 to n do begin write(ma[i,j]:4); if (ma[i,j]<-8) or (ma[i,j]>6) then ma[i,j]:=sqr(ma[i,j]); end; end; writeln; writeln('Final matrix:'); for i:=1 to n do begin writeln; for j:=1 to n do write(ma[i,j]:4); end; end.
Const
s=5;
Var
ar:array[1..s] of integer;
n,m,i:integer;
begin
writeln('N');
readln(n);
writeln('M');
readln(m);
writeln('Array:');
for i:=1 to s do
readln(ar[i]);
writeln('First array:');
for i:=1 to s do
begin
write(ar[i]:4);
if ar[i] div n<>0 then ar[i]:=ar[i]+m;
end;
writeln;
writeln('Final array:');
for i:=1 to s do
write(ar[i]:4);
end.
Пример ввода:
3
3
1
2
3
4
5
Пример вывода:
First array:
1 2 3 4 5
Final array:
1 2 6 7 8
//Блок-схема во вложении
Const
n=5;
Var
ma:array[1..n,1..n] of integer;
i,j:integer;
begin
writeln('Matrix reading...');
for i:=1 to n do
begin
writeln;
for j:=1 to n do
readln(ma[i,j]);
end;
writeln('First matrix:');
for i:=1 to n do
begin
writeln;
for j:=1 to n do
begin
write(ma[i,j]:4);
if (ma[i,j]<-8) or (ma[i,j]>6) then ma[i,j]:=sqr(ma[i,j]);
end;
end;
writeln;
writeln('Final matrix:');
for i:=1 to n do
begin
writeln;
for j:=1 to n do
write(ma[i,j]:4);
end;
end.
Пример ввода:
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
Пример вывода:
First matrix:
1 2 3 4 5
6 7 8 9 1
2 3 4 5 6
7 8 9 1 2
3 4 5 6 7
Final matrix:
1 2 3 4 5
6 49 64 81 1
2 3 4 5 6
49 64 81 1 2
3 4 5 6 49