

#include <string>
using namespace std;
string solution(string code) {
bool mode = 0;
//char one = 0x31; // 1
string ret = "";
for (int idx = 0; idx < code.length(); idx++)
{
if (0 == mode)
{
if ('1' == code[idx])
mode = 1;
else
if (0 == idx % 2)
ret += code[idx];
}
else
{
if ('1' == code[idx])
mode = 0;
else
if (1 == idx % 2)
ret += code[idx];
}
}
if ("" == ret)
return "EMPTY";
return ret;
}
문제를 제대로 읽자
: 짝수라는 설명만 보고 냅다 0 == idx일 경우를 제외시켜 버렸다.
예시를 보니 0일 때도 짝수로 보고 출력하고 있었다..
문자에 작은 따옴표 붙이기
: 1 == code[idx]가 아니라'1' == code[idx] 가 맞다.