//第二题---更好理解 int count_seq(string str, int low, int high) {  int result = 0;  if (high - low == 0) {   return 1;  }  if (high - low == 1) {   if (str[high] == str[low])    return 3;   else    return 2;  }  if (str[low] == str[high]) {   result = count_seq(str, low + 1, high) + count_seq(str, low, high - 1) + 1;  }  else {   result = count_seq(str, low + 1, high) + count_seq(str, low, high - 1) - count_seq(str, low + 1, high - 1);  }  return result; } int main() {  string str = "ABA";  cout << count_seq(str, 0, str.length() - 1) << endl; }
点赞 评论

相关推荐

被普调的六边形战士很高大:项目经历貌似和专业或者求职方向没大关系?
点赞 评论 收藏
分享
韵不凡:软件开发的工作需要博士吗?
点赞 评论 收藏
分享
牛客网
牛客企业服务