Thứ Ba, 3 tháng 5, 2022

VMSUBSTR PASCAL

var s:ansistring;
n,i,j,q,res:longint;

procedure nhap;
begin
        readln(n);
        readln(s);
end;

procedure giai;
var x:string;
        c:char;
begin
        readln(q);
        for i:=1 to q do
        begin

                readln(x);
                if pos(s[1],x)>0 then res:=1
                else res:=0;
                for j:=2 to n do
                        //if (d[s[j]]=1) and (d[s[j-1]]=0) then
                        if(pos(s[j],x)>0) and (pos(s[j-1],x)=0) then
                                inc(res);
                writeln(res);
        end;


end;

begin
        assign(input,'vmsubstr.inp');reset(input);
        assign(output,'vmsubstr.out');rewrite(output);
        nhap;
        giai;
end.


Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.