ai chuyển hộ mình bài game ZUMA này từ Pascal sang C++ với ạ, cảm ơn!
Program ZUMA;
Var
  n,k,i,l,r,res :Byte;
  S :String;
  ch :Char;
  ok :Boolean;
 
Begin
  ReadLn(n); 
  ReadLn(S); 
  ReadLn(k,ch,ch);
  Insert(ch,S,k); 
  ok:=false; 
  res:=0;
  repeat
    i:=k;
    while (S[i+1]=S[i]) do Inc(i);
    r:=i; i:=k;
    while (S[i-1]=S[i]) do Dec(i);
    l:=i;
    if (r-l+1>=3) then
      begin
        Inc(res,r-l+1); 
		Delete(S,l,r-l+1);
        if (S[l-1]=S[l]) then k:=l-1 else ok:=true;
      end
    else ok:=true;
  until ok;
  Write(res);
End.