procedure sortbutmeh(var ar:ty;n:integer); Var i,j,c:integer; begin for i:=1 to n-1 do for j:=i+1 to n do if ar[i]<ar[j] then begin c:=ar[i]; ar[i]:=ar[j]; ar[j]:=c; end; end;
begin randomize; readln(n); writeln('First array:'); for i:=1 to n do begin ar[i]:=random(100); write(ar[i]:4); end; sortbutmeh(ar,n); writeln; writeln('Array after sortbutmeh()'); for i:=1 to n do write(ar[i]:4); end.
//2) Var n:integer;
procedure ned(n:integer); begin case n of 1:writeln('Понедельник'); 2:writeln('Вторник'); 3:writeln('Среда'); 4:writeln('Четверг'); 5:writeln('Пятница'); 6:writeln('Суббота'); 7:writeln('Воскресенье'); end; end;
begin readln(n); ned(n); end.
//3) Var s:string;
function lengthbutmeh(s:string):integer; begin while pos(' ',s)<>0 do delete(s,pos(' ',s),1); lengthbutmeh:=length(s); end;
0001 = 2^3*0 + 2^2*0 + 2^1*0 + 2^0*1 = 0 + 0 + 0 + 1 = 1
0110 = 2^3*0 + 2^2*1 + 2^1*1 + 2^0*0 = 0 + 4 + 2 + 0 = 6
0001 = 2^3*0 + 2^2*0 + 2^1*0 + 2^0*1 = 0 + 0 + 0 + 1 = 1
0101 = 2^3*0 + 2^2*1 + 2^1*0 + 2^0*1 = 0 + 4 + 0 + 1 = 5
0100 = 2^3*0 + 2^2*1 + 2^1*0 + 2^0*0 = 0 + 4 + 0 + 0 = 4
1001 = 2^3*1 + 2^2*0 + 2^1*0 + 2^0*1 = 8 + 0 + 0 + 1 = 9
Если это одно большое число, то вот так
1000000101100001010101001001 = 2^27*1 + 2^26*0 + 2^25*0 + 2^24*0 + 2^23*0 + 2^22*0 + 2^21*0 + 2^20*1 + 2^19*0 + 2^18*1 + 2^17*1 + 2^16*0 + 2^15*0 + 2^14*0 + 2^13*0 + 2^12*1 + 2^11*0 + 2^10*1 + 2^9*0 + 2^8*1 + 2^7*0 + 2^6*1 + 2^5*0 + 2^4*0 + 2^3*1 + 2^2*0 + 2^1*0 + 20*1 = 134217728 + 0 + 0 + 0 + 0 + 0 + 0 + 1048576 + 0 + 262144 + 131072 + 0 + 0 + 0 + 0 + 4096 + 0 + 1024 + 0 + 256 + 0 + 64 + 0 + 0 + 8 + 0 + 0 + 1 = 135664969
^ - Возведение в степень
Type
ty=array[1..25] of integer;
Var
n,i:integer;
ar:ty;
procedure sortbutmeh(var ar:ty;n:integer);
Var
i,j,c:integer;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if ar[i]<ar[j] then
begin
c:=ar[i];
ar[i]:=ar[j];
ar[j]:=c;
end;
end;
begin
randomize;
readln(n);
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(100);
write(ar[i]:4);
end;
sortbutmeh(ar,n);
writeln;
writeln('Array after sortbutmeh()');
for i:=1 to n do
write(ar[i]:4);
end.
//2)
Var
n:integer;
procedure ned(n:integer);
begin
case n of
1:writeln('Понедельник');
2:writeln('Вторник');
3:writeln('Среда');
4:writeln('Четверг');
5:writeln('Пятница');
6:writeln('Суббота');
7:writeln('Воскресенье');
end;
end;
begin
readln(n);
ned(n);
end.
//3)
Var
s:string;
function lengthbutmeh(s:string):integer;
begin
while pos(' ',s)<>0 do
delete(s,pos(' ',s),1);
lengthbutmeh:=length(s);
end;
begin
readln(s);
writeln(lengthbutmeh(s));
end.