【題解】Green Judge g066: A.迴文

【題目敘述】http://www.tcgs.tc.edu.tw:1218/ShowProblem?problemid=g066
【Tag】迴圈、字串

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    string s;
    while (T--) {
        cin >> s;
        bool flag = true;
        for (int l = 0, r = s.size() - 1; l <= r; l++, r--) {
            if (s[l] != s[r]) {
                flag = false;
                break;
            }
        }
        if (flag) cout << "yes\n";
        else cout << "no\n";
    }
    return 0;
}
分享本文 Share with friends