uses crt; var i,j,max:byte; a: array [1..100] of integer; buf:integer; BEGIN repeat write(' input number of elements '); readln(max); until max in [1..100]; writeln('input your demention'); for i:=1 to max do begin write('input a[', i, '] = '); readln(a[i]); end; buf:=0; write('the first sort: '); for i:=max downto 1 do for j:=2 to i do if a[j]<a[j-1] then begin buf:=a[j]; a[j]:=a[j-1]; a[j-1]:=buf; end; for i:=1 to max do write(a[i]); writeln; write('the second sort : '); for i:=max downto 1 do write(a[i],' '); END. С форума программистов , сортировка повсюду
С форума программистов , сортировка повсюду
1)
program gt1;
var x,y:real;
begin
x:=-3.1;
while x<1 do
begin
x:=x+0.1;
y:=4*x*x*x-2*x*x+5;
writeln(y);
end;
end.
2)
program gt2;
var k,i:integer;
begin
k:=0;
for i:=11 to 20 do
begin
if(i mod 2=1)then k:=k+1;
end;
writeln(k);
end.
3)
program gt3;
var s,i:integer;
begin
s:=0;
for i:=1 to 100 do
begin
if(i mod 2=0)then s:=s+i;
end;
writeln(s);
end.
4)
program gt4;
var sum,a:real;
i,n:integer;
begin
sum:=0;
a:=0;
readln(n);
for i:=1 to n do begin
a:=1/((3*n-2)-(3*n+1));
Sum:=sum + a;
n:=n+1;
end;
write(sum);
end.
5)
program gt5;
var n,k:integer;
begin
k:=0;
while n>0 do
begin
n:=n div 10;
k:=k+1;
end;
writeln(k);
end.