Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
i,j,k:integer; s:real;
Begin
for i:=1 to n do
a[i]:=random(20)-10;
for i:=1 to n do
write(a[i], ' ');
for i:=1 to n do
for j:=1 to n-1 do
if (a[j]<a[j+1]) then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
end;
writeln('');
for i:=1 to n do
write(a[i], ' ');
s:=0;
for i:=1 to n do
if ((a[i] < 0)and(i mod 2=0)) then s:=s+1;
writeln('');
writeln(s);
End.
Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
i,j,k:integer; s:real;
Begin
for i:=1 to n do
a[i]:=random(20)-10;
for i:=1 to n do
write(a[i], ' ');
for i:=1 to n do
for j:=1 to n-1 do
if (a[j]<a[j+1]) then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
end;
writeln('');
for i:=1 to n do
write(a[i], ' ');
s:=0;
for i:=1 to n do
if ((a[i] < 0)and(i mod 2=0)) then s:=s+1;
writeln('');
writeln(s);
End.
Поделитесь своими знаниями, ответьте на вопрос:
Вычислить s= cos(x) + cos(x+1) + cos(x+2) + cos (x+n) n-натуральное число
===== PascalABC.NET =====
begin
var n := ReadInteger('n =');
var x := ReadReal('x =');
var s := Cos(x);
for var i := 1 to n do
s += Cos(x + i);
s.Println
end.