pascalABC
Объяснение:
var
a: array of integer;
i, j, n, k: integer;
begin
Write('Введите размер массива: '); ReadLn(n);
SetLength(a, n);
Randomize();
for i := 0 to n - 1 do begin
a[i] := random(201) - 100;
if a[i] > 0 then inc(k);
end;
for i := 0 to n - 2 do begin
if a[i] > 0 then continue;
for j := i + 1 to n - 1 do begin
if a[j] > 0 then begin
swap(a[i], a[j]); //перестановка элементов местами
break;
end;
end;
end;
for i := 0 to n - 1 do Write(a[i], ', '); WriteLn;
WriteLn('В массиве ', k, ' положительных элементов.');
end.
pascalABC
Объяснение:
var
a: array of integer;
i, j, n, k: integer;
begin
Write('Введите размер массива: '); ReadLn(n);
SetLength(a, n);
Randomize();
for i := 0 to n - 1 do begin
a[i] := random(201) - 100;
if a[i] > 0 then inc(k);
end;
for i := 0 to n - 2 do begin
if a[i] > 0 then continue;
for j := i + 1 to n - 1 do begin
if a[j] > 0 then begin
swap(a[i], a[j]); //перестановка элементов местами
break;
end;
end;
end;
for i := 0 to n - 1 do Write(a[i], ', '); WriteLn;
WriteLn('В массиве ', k, ' положительных элементов.');
end.
var
a: string;
x: integer;
begin
write('Введите слово: '); readln(a);
length(a);
if (a[2]='а') or (a[2]='б') or (a[2]='в') or (a[2]='г') or (a[2]='д') then x:=9;
if (a[2]='е') or (a[2]='ж') or (a[2]='з') or (a[2]='и') or (a[2]='й') or (a[2]='к') then x:=8;
if (a[2]='л') or (a[2]='м') or (a[2]='н') or (a[2]='о') or (a[2]='п') or (a[2]='р') then x:=7;
if (a[2]='с') or (a[2]='т') or (a[2]='у') or (a[2]='ф') or (a[2]='х') or (a[2]='ц') then x:=6;
if (a[2]='ч') or (a[2]='ш') or (a[2]='щ') or (a[2]='ы') or (a[2]='ъ') or (a[2]='ь') or (a[2]='э') or (a[2]='ю') or (a[2]='я') then x:=5;
writeln('Перевод: ', x);
end.