#include <iostream>
#include <cstring> // 需要添加这个头文件用于strlen
using namespace std;
const int N=1e6+9;
char s[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> (s+1); // 给定字符数组 s 的第二个位置开始接受输入
int n=(int)strlen(s+1); // 确保 strlen 返回值为整型
int l=1,r=n;
bool ans=true; // 将 'ture' 改为 'true'
while(l<r)
{
if(s[l]!=s[r]) ans=false;
l++, r--;
}
cout << (ans?"Y":"N") << endl;
return 0;
}
修改点说明:
- 将
ture
改成了正确的英语单词true
。 - 添加了
<cstring>
头文件,以便能够使用strlen()
函数。
其他部分代码无误,逻辑