这个代码有人能改成c++吗,我看不懂...
def min_operations_to_convert(A, B):
if sorted(A) != sorted(B) or len(A) != len(B):
return -1
len_A = len(A)
j = len_B - 1
operations = 0
for i in range(len_A):
if A[i] == B[j]:
j -= 1
if j < 0:
return operations
else:
operations += 1
return -1 if j != -1 else operations
# 示例
A = "abcde"
B = "edcba"
print(min_operations_to_convert(A, B))