Skip to content

Commit 3749099

Browse files
committed
[ADD] BOJ 10174 팰린드롬
- 구현
1 parent db62278 commit 3749099

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

acmicpc.net/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
| 203 | [알고리즘 수업 - 알고리즘의 수행 시간 4](https://www.acmicpc.net/problem/24265) | [cpp](source/24265.cpp) | 204 | [콘서트](https://www.acmicpc.net/problem/16466) | [cpp](source/16466.cpp) |
273273
| 205 | [저항](https://www.acmicpc.net/problem/1076) | [cpp](source/1076.cpp) | 206 | [공사장 표지판](https://www.acmicpc.net/problem/23055) | [cpp](source/23055.cpp) |
274274
| 207 | [Ресторан](https://www.acmicpc.net/problem/23738) | [cpp](source/23738.cpp) | 208 | [자동완성](https://www.acmicpc.net/problem/24883) | [cpp](source/24883.cpp) |
275+
| 209 | [팰린드롬](https://www.acmicpc.net/problem/10174) | [cpp](source/10174.cpp) | | | |
275276

276277
</details>
277278

acmicpc.net/source/10174.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// 10174. 팰린드롬
2+
// 2022.04.16
3+
// 구현
4+
#include<iostream>
5+
#include<string>
6+
7+
using namespace std;
8+
9+
int main()
10+
{
11+
int n;
12+
cin >> n;
13+
cin.ignore();
14+
string s;
15+
for (int i = 0; i < n; i++)
16+
{
17+
getline(cin, s);
18+
bool IsPalindrome = true;
19+
for (int i = 0; i < s.size(); i++)
20+
{
21+
if (s[i] >= 'A' && s[i] <= 'Z')
22+
{
23+
s[i] = tolower(s[i]);
24+
}
25+
}
26+
27+
for (int i = 0; i < s.size() / 2; i++)
28+
{
29+
if (s[i] != s[s.size() - i - 1])
30+
{
31+
IsPalindrome = false;
32+
break;
33+
}
34+
}
35+
if (IsPalindrome)
36+
{
37+
cout << "Yes" << endl;
38+
}
39+
else
40+
{
41+
cout << "No" << endl;
42+
}
43+
}
44+
return 0;
45+
}

0 commit comments

Comments
 (0)