Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
115520 | 彭士宝 | 31回文字符串 | C++ | Accepted | 1 MS | 280 KB | 670 | 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; }