Run ID:115520

提交时间:2025-03-31 15:19:54

#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; // 输入字符串 int n = s.length(); // 获取字符串长度 bool isPalindrome = true; // 假设字符串是回文字符串 // 使用双指针法判断是否为回文字符串 for (int i = 0, j = n - 1; i < j; ++i, --j) { if (s[i] != s[j]) { isPalindrome = false; // 如果发现不相等的字符,则不是回文字符串 break; } } // 输出结果 if (isPalindrome) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }