공부/SWEA
SWEA 4522. 세상의 모든 팰린드롬 (C++)
밤톨ㅇl
2024. 5. 6. 02:26
#include <iostream>
#include <string>
using namespace std;
string s;
int test()
{
int tc = 0;
cin >> tc;
for (int t = 1; t <= tc; t++)
{
bool flag = true;
cin >> s;
for (int i = 0; i < s.size() / 2; i++)
{
int end = s.size() - 1 - i;
if ( s[i] == '?' || s[end] == '?')
continue;
if (s[i] != s[end])
{
flag = false;
break;
}
}
if (flag)
cout << "#" << t << " Exist\n";
else
cout << "#" << t << " Not exist\n";
}
return 0;
}
둘 중에 하나라도 와일드카드가 있다면 넘어가기!!