👀 문제 설명
로그인해야 문제를 볼 수 있다
✍🏻풀이
단어의 앞과 뒤를 비교해나가면서 다를 경우 플래스 변수를 0으로 바꾸면 된다.
코드
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int T;
cin >> T;
for (int test_case = 1; test_case <= T; ++test_case) {
string word;
cin >> word;
int isTrue = 1;
for (int i = 0; i < word.length() / 2; i++) {
if (word[i] != word[word.length() - 1 - i]) {
isTrue = 0;
break;
}
}
cout << "#" << test_case << " " << isTrue << endl;
}
return 0;
}
'숨막히는 알고말고 > 문제 풀이' 카테고리의 다른 글
[SWEA] 신문 헤드라인 (0) | 2021.02.13 |
---|---|
[Baekjoon] 30번 (0) | 2021.02.11 |
[Baekjoon] 색종이 (0) | 2021.02.09 |
[Baekjoon] 스위치 켜고 끄기 (0) | 2021.02.08 |
[Baekjoon] 경비원 (0) | 2021.02.06 |