[YTU]_2803( 判断字符串是否为回文)

Description

编写程序,判断输入的一个字符串是否为回文。若是则输出“Yes”,否则输出“No”。所谓回文是指順读和倒读都是一样的字符串。

Input

Output

Sample Input

abcddcba

Sample Output

Yes
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char str[101];
    int i,n;
    gets(str);
    n=strlen(str);
    for(i=0;i<n/2;i++)
    {
        if(str[i]!=str[n-1-i])
        {   cout<<"No"<<endl;
        break;
        }
    }
    if(i==n/2)
        cout<<"Yes"<<endl;
    return 0;
}

原文地址:https://www.cnblogs.com/sxy201658506207/p/7586403.html