11.06.2007, 17:52
общий
это ответ
Здравствуйте, Максим Сергеевич!
По первому вопросу:
type ar = Record
n: integer;
s: string;
end;
var F: TextFile;
s,tmp: string;
A: Set of Char;
Mass: array[1..100] of ar;
n,count,i,j,max: integer;
begin
ClrScr;
Assign(F,‘text.txt‘);
Reset(F);
While not Eof(F) do
begin
n:=1;
Readln(F,s);
for j:=1 to Length(s) do
begin
if s[j]<>‘ ‘ then
begin
tmp:=tmp+s[j];
end else
begin
for i:=1 to Length(tmp) do
begin
if Not(tmp[i] in A) then
begin
Inc(count);
A:=A+[tmp[i]];
end;
end;
Mass[n].n:=count;
Mass[n].s:=tmp;
count:=0;
tmp:=‘‘;
Inc(n);
A:=[];
end;
end;
max:=0;
for i:=1 to n do
begin
if max<Mass[i].n then
begin
max:=Mass[i].n;
count:=i;
end;
end;
if max<>0 then Writeln(Mass[count].s,Mass[count].n);
end;
CloseFile(F);
ReadKey;
end.
По второму вопросу в приложении:
Приложение:
var F: TextFile; s,st: string; p,count,i: integer;begin ClrScr; count:=0; Write(‘Input test word : ‘); Read(st); Assign(F,‘text.txt‘); Reset(F); count:=0; While not Eof(F) do begin Readln(F,s); While Pos(st,s)<>0 do begin p:=Pos(st,s); if p<>0 then begin Inc(count); for i:=p to p+Length(st) do s[i]:=‘ ‘; end; end; end; if count<>0 then begin Write(‘Slovo ‘+st+‘ vstrechaetsya ‘); Write(count); Writeln(‘ raz!‘); end; CloseFile(F); ReadKey;end.