Агеевич
5 год назад
Цикл For . Pascal
Помогите пожалуйста!
ОТВЕТЫ
Zinovevich
Jun 29, 2019
1.
var x:integer; y:real;
begin
for x:=-5 to 10 do
begin
y:=cos(x);
writeln(x:3,y:7:3);
end;
end.
Результат:
-5 0.284
-4 -0.654
-3 -0.990
-2 -0.416
-1 0.540
0 1.000
1 0.540
2 -0.416
3 -0.990
4 -0.654
5 0.284
6 0.960
7 0.754
8 -0.146
9 -0.911
10 -0.839
2.
var x,s:real; n,i:integer;
begin
write(x = ); readln(x);
write(n = ); readln(n);
s:=0;
for i:=1 to n do s:=s+sin(i*x);
writeln(s = ,s:7:4);
end.
Пример:
x = 2
n = 5
s = 0.3184
var x:integer; y:real;
begin
for x:=-5 to 10 do
begin
y:=cos(x);
writeln(x:3,y:7:3);
end;
end.
Результат:
-5 0.284
-4 -0.654
-3 -0.990
-2 -0.416
-1 0.540
0 1.000
1 0.540
2 -0.416
3 -0.990
4 -0.654
5 0.284
6 0.960
7 0.754
8 -0.146
9 -0.911
10 -0.839
2.
var x,s:real; n,i:integer;
begin
write(x = ); readln(x);
write(n = ); readln(n);
s:=0;
for i:=1 to n do s:=s+sin(i*x);
writeln(s = ,s:7:4);
end.
Пример:
x = 2
n = 5
s = 0.3184
147
Смежные вопросы: