1) цикл с параметром: var x,b,v,b0,bk,db:real; i:integer; begin writeln('Введите b0, bk, db:'); readln(b0,bk,db); x:=0.5; b:=b0-db; for i:=1 to round((bk-b0)/db)+1 do begin b:=b+db; if b>3.7 then v:=cos(b*x) else if b=3.7 then v:=x+2*sin(b*x) else v:=b*b+sqrt(x); writeln(b:4:1,v:8:3); end; end.
2) цикл с предусловием: var x,b,v,b0,bk,db:real; begin writeln('Введите b0, bk, db:'); readln(b0,bk,db); x:=0.5; b:=b0-db; while b<bk do begin b:=b+db; if b>3.7 then v:=cos(b*x) else if b=3.7 then v:=x+2*sin(b*x) else v:=b*b+sqrt(x); writeln(b:4:1,v:8:3); end; end.
3) цикл с постусловием: var x,b,v,b0,bk,db:real; begin writeln('Введите b0, bk, db:'); readln(b0,bk,db); x:=0.5; b:=b0-db; repeat b:=b+db; if b>3.7 then v:=cos(b*x) else if b=3.7 then v:=x+2*sin(b*x) else v:=b*b+sqrt(x); writeln(b:4:1,v:8:3); until b>=bk; end.
Answers & Comments
Verified answer
1) цикл с параметром:var x,b,v,b0,bk,db:real;
i:integer;
begin
writeln('Введите b0, bk, db:');
readln(b0,bk,db);
x:=0.5;
b:=b0-db;
for i:=1 to round((bk-b0)/db)+1 do
begin
b:=b+db;
if b>3.7
then v:=cos(b*x)
else if b=3.7 then v:=x+2*sin(b*x)
else v:=b*b+sqrt(x);
writeln(b:4:1,v:8:3);
end;
end.
2) цикл с предусловием:
var x,b,v,b0,bk,db:real;
begin
writeln('Введите b0, bk, db:');
readln(b0,bk,db);
x:=0.5;
b:=b0-db;
while b<bk do
begin
b:=b+db;
if b>3.7
then v:=cos(b*x)
else if b=3.7 then v:=x+2*sin(b*x)
else v:=b*b+sqrt(x);
writeln(b:4:1,v:8:3);
end;
end.
3) цикл с постусловием:
var x,b,v,b0,bk,db:real;
begin
writeln('Введите b0, bk, db:');
readln(b0,bk,db);
x:=0.5;
b:=b0-db;
repeat
b:=b+db;
if b>3.7
then v:=cos(b*x)
else if b=3.7 then v:=x+2*sin(b*x)
else v:=b*b+sqrt(x);
writeln(b:4:1,v:8:3);
until b>=bk;
end.
Пример:
Введите b0, bk, db:
1 5 0.5
1.0 1.707
1.5 2.957
2.0 4.707
2.5 6.957
3.0 9.707
3.5 12.957
4.0 -0.416
4.5 -0.628
5.0 -0.801