задача 3
Объяснение:
код написан на delphi/pascal
program Task3;
{$APPTYPE CONSOLE}
uses
SysUtils;
const
Alpha: set of Char = ['A'..'Z','А'..'П','Р'..'Я','a'..'z','а'..'п','р'..'я'];
var
s: String;
i: Integer;
wc: Integer;
begin
Readln(s);
i := 1; wc := 0;
repeat
while not (s[i] in Alpha) and (i <= Length(s)) do Inc(i);
if (i <= Length(s)) then Inc(wc);
while (s[i] in Alpha) and (i <= Length(s)) do Inc(i);
until i > Length(s);
Writeln('Num words -> ',wc);
readln;
end.
1)program pr;
a: array [1..100] of integer;
i, temp,n, j: integer;
writeln('Введите размер массива');
readln(n);
for i := 1 to n do
a[i] := random(100, 999);
write(a[i]:4);
end;
for j := 1 to n - i do
if ((a[j] div 10) mod 10) > ((a[j + 1] div 10) mod 10) then
temp := a[j];
a[j] := a[j + 1];
a[j + 1] := temp;
writeln;
2)var a: array [1..5] of integer; i, amount: integer;
read(a[1], a[2], a[3], a[4], a[5]);
amount := 0;
for i := 1 to 5 do
while a[i] >= 10 do
a[i] := a[i] div 10;
if a[i] = 8
then
amount := amount + 1;
writeln(amount);
3)var i, c1, c2, k: integer;
stroka, slovo: string;
write ('stroka=');
readln(stroka);
k:=0;
stroka:=stroka+' ';
c1:=1;
c2:=1;
for i:=2 to length (stroka) do
if stroka[i] = ' ' then
c2:=i;
slovo:=copy (stroka, c1, c2-c1);
if slovo[length(slovo)]=slovo[1] then
inc (k);
write (slovo,' ');
c1:=c2+1;
writeln ('всего слов = ', k) ;
задача 3
Объяснение:
код написан на delphi/pascal
program Task3;
{$APPTYPE CONSOLE}
uses
SysUtils;
const
Alpha: set of Char = ['A'..'Z','А'..'П','Р'..'Я','a'..'z','а'..'п','р'..'я'];
var
s: String;
i: Integer;
wc: Integer;
begin
Readln(s);
i := 1; wc := 0;
repeat
while not (s[i] in Alpha) and (i <= Length(s)) do Inc(i);
if (i <= Length(s)) then Inc(wc);
while (s[i] in Alpha) and (i <= Length(s)) do Inc(i);
until i > Length(s);
Writeln('Num words -> ',wc);
readln;
end.
1)program pr;
var
a: array [1..100] of integer;
i, temp,n, j: integer;
begin
writeln('Введите размер массива');
readln(n);
for i := 1 to n do
begin
a[i] := random(100, 999);
write(a[i]:4);
end;
for i := 1 to n do
for j := 1 to n - i do
if ((a[j] div 10) mod 10) > ((a[j + 1] div 10) mod 10) then
begin
temp := a[j];
a[j] := a[j + 1];
a[j + 1] := temp;
end;
writeln;
for i := 1 to n do
write(a[i]:4);
end.
2)var a: array [1..5] of integer; i, amount: integer;
begin
read(a[1], a[2], a[3], a[4], a[5]);
amount := 0;
for i := 1 to 5 do
begin
while a[i] >= 10 do
begin
a[i] := a[i] div 10;
end;
if a[i] = 8
then
amount := amount + 1;
end;
writeln(amount);
end.
3)var i, c1, c2, k: integer;
stroka, slovo: string;
begin
write ('stroka=');
readln(stroka);
k:=0;
stroka:=stroka+' ';
c1:=1;
c2:=1;
for i:=2 to length (stroka) do
if stroka[i] = ' ' then
begin
c2:=i;
slovo:=copy (stroka, c1, c2-c1);
if slovo[length(slovo)]=slovo[1] then
begin
inc (k);
write (slovo,' ');
end;
c1:=c2+1;
end;
writeln;
writeln ('всего слов = ', k) ;
end.