#31026: 因為這題我終於分清楚string和char的差別了!


jason096727@gmail.com (Jason Ho)

學校 : 高雄市苓雅區福東國民小學
編號 : 189939
來源 : [150.116.71.76]
最後登入時間 :
2023-07-15 21:32:51
a022. 迴文 | From: [150.116.71.227] | 發表日期 : 2022-07-05 21:43

#include <iostream>
using namespace std;
int main()
{
    string x;
    int b=1;
    cin >> x;
    for (int i=0; i<x.length()/2; i++){
        if (x[i]!=x[x.length()-1-i]){
            b=0;
        }
    }
    if (b==1){
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
    return 0;
}

 
ZeroJudge Forum