1. 문제
https://level.goorm.io/exam/48192/%ED%9A%8C%EB%AC%B8/quiz/1
2. 소스코드
#include <iostream>
#define PALIN 0
#define PSEUDO 1
#define NONE 2
using namespace std;
int T;
bool isPalin(string str){
int len = str.length();
for(int i = 0 ; i <= len/2; ++i){
if(str[i] != str[len-1-i]) return false;
}
return true;
}
bool isPseudo(string str){
int len = str.length();
string temp;
for(int i = 0; i < len - 1; ++i){
temp = str;
//cout << " temp.earse(i,0) "<< temp.erase(i,1) << '\n';
if(isPalin(temp.erase(i,1))){
return true;
}
}
return false;
}
int main() {
cin >> T;
while(T--){
string str;
cin >> str;
if(isPalin(str)){
cout << PALIN << '\n';
}
else if(isPseudo(str)) {
cout << PSEUDO << '\n';
}
else {
cout << NONE << '\n';
}
}
return 0;
}
'알고리즘 > 구름' 카테고리의 다른 글
[ 구름 / 그리디 ] 거스름돈 풀이 (0) | 2020.06.29 |
---|---|
[ 구름 / 문자열 ] 거울 단어 풀이 (0) | 2020.06.29 |
[ 구름 / 단순 구현 ] 막대기 풀이 (0) | 2020.06.29 |
[ 구름 / 문자열 ] 앵무새 꼬꼬 (0) | 2020.06.28 |
[ 구름 / 단순 구현 ] 고장난 컴퓨터 풀이 (0) | 2020.06.27 |