URI 문제 질문입니다~

  • powermike
    powermike

    c++로 문제를 풀어봤는데요
    어느 부분이 잘못되었는지 계속 오답이 나와서요
    코드 지적 좀 부탁드리겠습니다~

    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        int iTestCase = 0;
    
        cin >> iTestCase;
    
        while (iTestCase--)
        {
            string sInput;
            cin >> sInput;
    
            int iSize = sInput.length();
    
            for (int iIndex = 0; iIndex < iSize; iIndex++)
            {
                char x = 0;
                if (sInput[iIndex] == '%')  
                {
                    if(sInput[iIndex + 1])
                    x += 16 * (sInput[iIndex + 1]-48);
                    switch (sInput[iIndex + 2])
                    {
                        case 'a': case 'A': x += 11; break;
                        case 'b': case 'B': x += 12; break;
                        case 'c': case 'C': x += 13; break;
                        case 'd': case 'D': x += 14; break;
                        case 'e': case 'E': x += 15; break;
                        case 'f': case 'F': x += 16; break;
                        default: x+= (sInput[iIndex + 2] - 48); break;
                    }
    
                    sInput[iIndex] = x;
                    sInput.erase(iIndex + 1, 2);
                    iSize -= 2;
                }
            }
            cout << sInput << endl;
        }
        return 0;
    }
    

    6년 전
1개의 댓글이 있습니다.
  • Corea
    Corea

    %00의 출력이 공백이 될 것 같네요.


    6년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.