Цитата:
Сообщение от Black_Betty
Написать на Паскале
|
Разрешите доложить: задание выполнено!
Код:
Var
S:String;
W:Array[1..100] of String;
i,j,Nw,Nsymb:Byte;
b,b1:boolean;
Begin
Writeln('Enter the string:');
Readln(S);
Nw:=1;
i:=0;
W[Nw]:='';
Repeat
Inc(i);
If (S[i]<>' ') and (i<=Length(S)) then
W[Nw]:=W[Nw]+S[i]
else
If S[i]=' ' then
begin
Inc(Nw);
W[Nw]:='';
end;
Until i>Length(S);
Nsymb:=0;
Repeat
Inc(Nsymb);
b:=true;
b1:=false;
For i:=1 to Nw do
If Length(W[i])<Nsymb then b1:=true;
If Not(b1) then
For i:=1 to Nw-1 do
For j:=i+1 to Nw do
If W[i][Nsymb]=W[j][Nsymb] then b:=false;
Until b or b1;
If b1 then
Writeln('No solution!')
else
Writeln('Minimal number of symbols is ',Nsymb);
Readln
End.
Разрешите быть свободным?