Run ID:97216
提交时间:2024-11-10 22:24:13
#include <iostream> #include <string> using namespace std; bool isPalindrome(string str) { int n = str.length(); for (int i = 0; i < n / 2; i++) { if (str[i]!= str[n - i - 1]) { return false; } } return true; } int main() { string input; cout << "请输入一个字符串: "; cin >> input; if (isPalindrome(input)) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }