#includeusing namespace std; #include vector s; int main() { int n; cin >> n; if (n < 0)return false; //负数不是回文数 while (n) { s.push_back(n % 10); n /= 10; } int len = s.size(); //将数字转换为数组 int left = 0, right = len - 1; while (left <= right) { if (s[left] != s[right]) { cout << "不是回文数" << endl; return 0;//不能掉 } else { left++; right--;//左指针右移,右指针左移; } } cout << "是回文数" << endl; return 0; }



