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 = 50; // количество чиселvar k: array [1..n] of integer; i, j, n1, n2, minr, a, b: integer; begin writeln(n, ' ', ': d'); a : = random(1000); b : = random(1000); minr : = 10000; for i : = 1 to n do k[i] : = a + random(b); for i : = 1 to n do for j : = 1 to n do if ((abs(k[i] - k[j])) < minr) and (k[i] < > k[j]) then begin minr : = abs(k[i] - k[j]); n1 : = i; n2 : = j; end; writeln(n1, ' ', n2); 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
//Блок-схема во вложении