Переделать код с Pascal на C++ uses StrUtils; var a : String; b: String[100]; i, j, c, k: Integer; t: array of String; begin ReadLn(a); ReadLn(b); SetLength(t, Length(b)); for i: = 1 to Length(b) do begin b : = Copy(b, 2, Length(b)) + b[1]; j: = k - 1; while (j >= 0) and (t[j]<>b) do Dec(j); if j < 0 then begin t[k]: = b; Inc(k); j: = PosEx(b, a, 1); while j > 0 do begin Inc(c); j: = PosEx(b, a, 1 + j); end; end; end; WriteLn(c); end.
int main() {
int c = 0;std::string a, b;
std::cin >> a >> b;
int k = 0;
std::vector<std::string> t(b.length());
for (int i = 0; i < b.length(); i++) {
b = b.substr(1) + b[0];
int j = k - 1;
while (j >= 0 && t[j] != b) {
j--;
}
if (j < 0) {
t[k] = b;
k++;
size_t pos = a.find(b, 0);
while (pos != std::string::npos) {
c++;
pos = a.find(b, pos + 1);
}
}
}
std::cout << c << std::endl;
return 0;
}