URL

Programming/AlgoSpot 2014. 7. 1. 00:30

문제 정보

문제

URI (Uniform Resource Identifier) is a compact string used to identify or name resources on the Internet. Some examples of URI are below:

  • http://icpc.baylor.edu.cn/
  • mailto:foo@bar.org
  • ftp://127.0.0.1/pub/linux
  • readme.txt

When transmitting *URI*s through the Internet, we escape some special characters in *URI*s with percent-encoding. Percent-encoding encodes an ASCII character into a percent sign ("%") followed by a two-digit Hexadecimal representation of the ASCII number. The other characters are not touched in the encoding process. The following table shows the special characters and their corresponding encodings:

Special CharacterEncoded String
" "%20
"!"%21
"$"%24
"%"%25
"("%28
")"%29
"*"%2a

Note that the quotes are for clarity only.

Write a program which reverses this process.

입력

The first line of the input file will contain the number of test cases C (1C100). The following Clines will each contain a test case — which is the percent-encoded URI. Their length will be at most 80.

출력

Print one line for each test cases — the decoded original URI.

예제 입력

2
Happy%20Joy%20Joy%21
http://algospot.com/%2a

예제 출력

Happy Joy Joy!
http://algospot.com/*


210583URIwowrupicpp968B정답2ms


1.문제설명
URL

2.알고리즘
string 변환

3.소스코드
#include <stdio.h>
#include <string.h>

int main(void)
{
int Case, i;
char str[81]={0,};
scanf("%d", &Case);

while(Case--)
{
scanf("%s", str);

for(i=0;i<strlen(str);i++)
{
if(str[i]=='%'&&str[i+1]=='2')
{
if(str[i+2]=='0')
{
putchar(' ');
i+=2;
continue;
}
else if(str[i+2]=='1')
{
putchar('!');
i+=2;
continue;
}
else if(str[i+2]=='4')
{
putchar('$');
i+=2;
continue;
}
else if(str[i+2]=='5')
{
putchar('%');
i+=2;
continue;
}
else if(str[i+2]=='8')
{
putchar('(');
i+=2;
continue;
}
else if(str[i+2]=='9')
{
putchar(')');
i+=2;
continue;
}
else if(str[i+2]=='a')
{
putchar('*');
i+=2;
continue;
}

}
putchar(str[i]);
}
putchar('\n');
memset(str, 0,sizeof(str));
}

return 0;
}

4.문제후기
초! 초급문제 알고스팟 초심자용문제에 있길래 풀어봤는데 
역시 초심자용
제출횟수가 2672인데 정답횟수가 934(34%)길래 그래도 풀어볼만하겠다 싶었는데 너무쉬었음


'Programming > AlgoSpot' 카테고리의 다른 글

등산로  (0) 2014.05.28