всё работает,только есть одно но...если есть строка фбсфбсфбс и подстрока фбс, и Н=3, то прога выдает ответ 0..
вот сама программа
Код
uses crt;
var st,p:string;
i,j,n,nn,t,count:integer;
f:boolean;
begin
clrscr;
write('введите строку S: ');
readln(st);
write('введите подстроку P: ');
readln(p);
write('введите N: ');
readln(n);
count:=0;
for i:=1 to length(st)-length(p) do
begin
f:=true;
t:=i;
for j:=1 to length(p) do
begin
if st[t]<>p[j] then f:=false;
inc(t);
end;
if f then
begin
inc(count);
nn:=i;
end;
if count=n then break;
end;
//for i:=1 to length(st) do
//writeln(st[i]);
if count=n then writeln(nn) else write('0');
readln;
end.
var st,p:string;
i,j,n,nn,t,count:integer;
f:boolean;
begin
clrscr;
write('введите строку S: ');
readln(st);
write('введите подстроку P: ');
readln(p);
write('введите N: ');
readln(n);
count:=0;
for i:=1 to length(st)-length(p) do
begin
f:=true;
t:=i;
for j:=1 to length(p) do
begin
if st[t]<>p[j] then f:=false;
inc(t);
end;
if f then
begin
inc(count);
nn:=i;
end;
if count=n then break;
end;
//for i:=1 to length(st) do
//writeln(st[i]);
if count=n then writeln(nn) else write('0');
readln;
end.