[백준/C++] 5789 - 한다 안한다

orangesnail·2025년 8월 18일

백준

목록 보기
144/169

https://www.acmicpc.net/problem/5789


중간 문자 두개만 비교하기 위해 (전체길이/2-1) 인덱스의 글자와 (전체길이/2) 인덱스의 글자를 비교한다.

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;

    while (n--) {
        string nums;
        cin >> nums;

        int len = nums.size();

        if (nums[len/2 - 1] == nums[len/2])
            cout << "Do-it" << endl;
        else
            cout <<"Do-it-Not" << endl;
    }
    return 0;
}
profile
초보입니다. 피드백 환영합니다 😗

0개의 댓글