酷代码 AI
菜单
服务商

C++实现字符串拼接并判断是否为回文串

```cpp #include <iostream> #include <string> using namespace std; // 检查字符串是否为回文串 bool isPalindrome(const string& s) { int left = 0, right = s.length() - 1; while (left < right) { if (s[left] != s[right]) { return false; } left++; right--; } return true; } int main() { int n; cin >> n; string result; for (int i = 0; i < n; i++) { string temp; cin >> temp; result += temp; } if (isPalindrome(result)) { cout << "yes" << endl; } else { cout << "no" << endl; } return 0; } ``` ######[AI问答 | 231点数解答 | 2026-05-16 20:29:30]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]