{
"question_id": 364242, "question_title": "回文串", "question_content": "题目描述\n回文串是从左到右或者从右到左读起来都一样的字符串,试编程判别一个字符串是否为回文串。\n输入\n输入一个字符串。串长度<255.\n输出\n判别输入的字符串是否为回文串,是回文串输出\"Y\",否则输出\"N\"。\n样例输入\nabcba\n样例输出\nY\n", "difficulty": "简单", "answer_id": 385629, "answer_content": "\n\n```\n #include<iostream>\n#include<string.h>\nusing namespace std;\n\nint main(void)\n{\n char *p=\"abcba\";\n int n=strlen(p);\n bool flag=1;\n int i;\n for(i=0;i<n/2;i++)\n {\n cout<<p[i]<<\"\\t\"<<p[n-1-i]<<endl;\n if(p[i]!=p[n-1-i])\n {\n flag=0;\n cout<<\"no\"<<endl;break;\n }\n }\n if(flag==1)\n cout<<\"yes\"<<endl;\n return 0;\n}\n```\n\n", "tag_name": "c++", "cpp": "#include<iostream>\n#include<string.h>\nusing namespace std;\nint main(void)\n{\n\tchar *p=\"abcba\";\n\tint n=strlen(p);\n\tbool flag=1;\n\tint i;\n\tfor(i=0;i<n/2;i++)\n\t{\n\t\tcout<<p[i]<<\"\\t\"<<p[n-1-i]<<endl;\n\t\tif(p[i]!=p[n-1-i])\n\t\t{\n\t\t\tflag=0;\n\t\t\tcout<<\"N\"<<endl;break;\n\t\t}\n\t}\n\tif(flag==1)\n\t\tcout<<\"Y\"<<endl;\n\treturn 0;\n}", "topic_link": "https://bbs.csdn.net/topics/600469941", "status": 1, "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配", "license": "csdn.net", "notebook": { "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/34.ipynb?type=file" }, "notebook_enable": 1, "author": "conris"
}