C++11 我想检查字符串是否为回文 chars[100]; //chart[100]; 整数计数=1; int j=0; int x,i; cin>>s; x=斯特伦(s); //cout
由于条件C++11 我想检查字符串是否为回文 chars[100]; //chart[100]; 整数计数=1; int j=0; int x,i; cin>>s; x=斯特伦(s); //cout,c++11,for-loop,if-statement,palindrome,C++11,For Loop,If Statement,Palindrome,由于条件i=x-1和i>s,您的代码从未为循环输入for; x=斯特伦(s); i=x-1; 欢迎来到堆栈溢出!你能详细说明你的代码是如何“不工作”的吗?你在期待什么,到底发生了什么?如果您遇到异常/错误,请发布发生该异常/错误的行以及异常/错误详细信息。请输入这些详细信息,否则我们可能无法提供帮助。条件ifor(int i=x-1;i char s[100]; //char t[100]; int count = 1; int j=0; int x,i; cin >>s; x=st
i=x-1和i>s,您的代码从未为循环输入for
;
x=斯特伦(s);
i=x-1;
欢迎来到堆栈溢出!你能详细说明你的代码是如何“不工作”的吗?你在期待什么,到底发生了什么?如果您遇到异常/错误,请发布发生该异常/错误的行以及异常/错误详细信息。请输入这些详细信息,否则我们可能无法提供帮助。条件ifor(int i=x-1;i
char s[100];
//char t[100];
int count = 1;
int j=0;
int x,i;
cin >>s;
x=strlen(s);
//cout <<x <<endl;
cout <<s[j] <<endl;
i=x-1;
cout <<s[i] <<endl;
for (int i = x-1; i <= 0; i--)
{
if (s[j] != s[i])
{
count = 0;
}
j++;
}
if ( count )
{
cout <<"YES";
}
else
{
cout <<"NO";
}
return 0;
#include <iostream>
using namespace std;
int main() {
char s[100];
int x,i,j=0;
cin >>s;
x=strlen(s);
i = x-1;
cout <<s[0] <<endl;
cout <<s[i] <<endl;
for (int i = x-1; i >= 0; i--)
{
if (s[j] != s[i])
{
cout <<"NO";
return 0;
}
j ++;
}
cout <<"YES";
return 0;
}