CHATCHIT - Chat chit

Tác giả: flashmt

Ngôn ngữ: Pascal

const a:array[1..13] of string[3]=('k','ko','ng','n','dc','hok','ntn','kq','j','w','f','dz','z');
      b:array[1..13] of string[11]=('khong','khong','nguoi','nhieu','duoc','khong','nhu the nao',
      'ket qua','gi','qu','ph','d','d');
var s,s1:string;
    i,j:byte;
    c1,c2:char;

begin
     read(s);
     for i:=1 to 13 do
     begin
          s1:=s;
          j:=pos(a[i],s1);
          while j<>0 do
          begin
               c1:=s[j+length(a[i])]; c2:=s[j-1];
               if ((ord(c1)<97) or (ord(c1)>122)) and ((ord(c2)<97) or (ord(c2)>122)) or (i>8) then
               begin
                    delete(s,j,length(a[i]));
                    insert(b[i],s,j);
                    delete(s1,j,length(a[i]));
                    insert(b[i],s1,j);
               end
               else s1[j]:='z';
               j:=pos(a[i],s1);
          end;
     end;
     write(s);
end.

Download