var a,b,c,d,min:real;
flag: boolean;
begin
flag:=true;
writeln('Enter A, B, C, D numbers:');
readln(a,b,c,d);
if (a=d) then begin
writeln('a equals to d!');
flag:=false;
min:=a;
end;
if (b=d) then begin
writeln('b equals to d!');
if (b<min) then min:=b;
if (c=d) then begin
writeln('c equals to d!');
if (c<min) then min:=c;
if flag then writeln('Max difference: ',d-min);
end.
const n=6;
var
p:array[1..n,1..n] of real;
i,j:integer;
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
for j:=1 to n do
p[i,j]:=10*random-5;
write(p[i,j]:6:1);
writeln;
for i:=1 to n do begin
for j:=1 to i-1 do p[i,j]:=round(p[i,j]);
for j:=i+1 to n do p[i,j]:=0;
writeln('Полученный массив:');
for j:=1 to n do write(p[i,j]:6:1);
Пример:
Исходный массив:
-1.8 4.9 -1.2 3.2 1.9 -2.0
4.5 4.9 4.8 -0.6 -2.5 1.2
2.3 0.3 1.1 0.3 -3.0 2.5
1.7 -0.5 2.2 -3.6 -3.6 -4.4
-0.4 -4.7 1.9 -3.8 -0.7 0.1
-4.4 -3.2 -4.5 -4.8 1.5 3.4
Полученный массив:
-1.8 0.0 0.0 0.0 0.0 0.0
5.0 4.9 0.0 0.0 0.0 0.0
2.0 0.0 1.1 0.0 0.0 0.0
2.0 -1.0 2.0 -3.6 0.0 0.0
0.0 -5.0 2.0 -4.0 -0.7 0.0
-4.0 -3.0 -5.0 -5.0 1.0 3.4
var a,b,c,d,min:real;
flag: boolean;
begin
flag:=true;
writeln('Enter A, B, C, D numbers:');
readln(a,b,c,d);
if (a=d) then begin
writeln('a equals to d!');
flag:=false;
min:=a;
end;
if (b=d) then begin
writeln('b equals to d!');
flag:=false;
if (b<min) then min:=b;
end;
if (c=d) then begin
writeln('c equals to d!');
flag:=false;
if (c<min) then min:=c;
end;
if flag then writeln('Max difference: ',d-min);
end.
const n=6;
var
p:array[1..n,1..n] of real;
i,j:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to n do
begin
p[i,j]:=10*random-5;
write(p[i,j]:6:1);
end;
writeln;
end;
for i:=1 to n do begin
for j:=1 to i-1 do p[i,j]:=round(p[i,j]);
for j:=i+1 to n do p[i,j]:=0;
end;
writeln('Полученный массив:');
for i:=1 to n do
begin
for j:=1 to n do write(p[i,j]:6:1);
writeln;
end;
end.
Пример:
Исходный массив:
-1.8 4.9 -1.2 3.2 1.9 -2.0
4.5 4.9 4.8 -0.6 -2.5 1.2
2.3 0.3 1.1 0.3 -3.0 2.5
1.7 -0.5 2.2 -3.6 -3.6 -4.4
-0.4 -4.7 1.9 -3.8 -0.7 0.1
-4.4 -3.2 -4.5 -4.8 1.5 3.4
Полученный массив:
-1.8 0.0 0.0 0.0 0.0 0.0
5.0 4.9 0.0 0.0 0.0 0.0
2.0 0.0 1.1 0.0 0.0 0.0
2.0 -1.0 2.0 -3.6 0.0 0.0
0.0 -5.0 2.0 -4.0 -0.7 0.0
-4.0 -3.0 -5.0 -5.0 1.0 3.4