【題解】Codeforces GYM 101652 N.Odd Palindrome

【題目敘述】http://codeforces.com/gym/101652/attachments Problem N

#include <iostream>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    char pre = s[0];
    bool odd = true;
    for (int i = 1; i < s.size(); i++){
        if (s[i] == pre){
            odd = false;
            break;
        } else {
            pre = s[i];
        }
    }
    if (odd) cout << "Odd.\n";
    else cout << "Or not.\n";
    return 0;
}
分享本文 Share with friends