POJ 3650:The Seven Percent Solution
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7684 | Accepted: 5159 |
Description
Uniform Resource Identifiers (or URIs) are strings like http://icpc.baylor.edu/icpc/, mailto:foo@bar.org, ftp://127.0.0.1/pub/linux, or even just readme.txt that are used to identify a resource, usually on the Internet
or a local computer. Certain characters are reserved within URIs, and if a reserved character is part of an identifier then it must be percent-encoded by replacing it with a percent sign followed by two hexadecimal digits representing the ASCII
code of the character. A table of seven reserved characters and their encodings is shown below. Your job is to write a program that can percent-encode a string of characters.
Character | Encoding |
" " (space) | %20 |
"!" (exclamation point) | %21 |
"$" (dollar sign) | %24 |
"%" (percent sign) | %25 |
"(" (left parenthesis) | %28 |
")" (right parenthesis) | %29 |
"*" (asterisk) | %2a |
Input
The input consists of one or more strings, each 1–79 characters long and on a line by itself, followed by a line containing only "#" that signals the end of the input. The character "#" is used only as an end-of-input marker and will not appear anywhere
else in the input. A string may contain spaces, but not at the beginning or end of the string, and there will never be two or more consecutive spaces.
Output
For each input string, replace every occurrence of a reserved character in the table above by its percent-encoding, exactly as shown, and output the resulting string on a line by itself. Note that the percent-encoding for an asterisk is %2a (with a lowercase
"a") rather than %2A (with an uppercase "A").
Sample Input
Happy Joy Joy!
http://icpc.baylor.edu/icpc/
plain_vanilla
(**)
?
the 7% solution
#
Sample Output
Happy%20Joy%20Joy%21
http://icpc.baylor.edu/icpc/
plain_vanilla
%28%2a%2a%29
?
the%207%25%20solution
Source
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include<stdio.h>
#include <string.h>
int main()
{
char str[80];
while(gets(str) && strcmp(str, "#") != 0)
{
int i, len = strlen(str);
for(i = 0; i < len; i++)
{
if(str[i] == ' ')
printf("%%20");
else if(str[i] == '!')
printf("%%21");
else if(str[i] == '$')
printf("%%24");
else if(str[i] == '%')
printf("%%25");
else if(str[i] == '(')
printf("%%28");
else if(str[i] == ')')
printf("%%29");
else if(str[i] == '*')
printf("%%2a");
else printf("%c",str[i]);
}
printf("\n");
}
return 0;
}
POJ 3650:The Seven Percent Solution的更多相关文章
- HDUOJ-------2719The Seven Percent Solution
The Seven Percent Solution Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- zoj 2932 The Seven Percent Solution
The Seven Percent Solution Time Limit: 2 Seconds Memory Limit: 65536 KB Uniform Resource Identi ...
- The Seven Percent Solution
Problem Description Uniform Resource Identifiers (or URIs) are strings like http://icpc.baylor.edu/i ...
- HDU 2719 The Seven Percent Solution
#include <cstdio> #include <cstring> int main() { ]; ]!='#') { ; while (i<strlen(s)) ...
- HDU 2719 The Seven Percent Solution (水题。。。)
题意:把字符串中的一些特殊符号用给定的字符串代替. 析:没的说. 代码如下: #include <iostream> #include <cstdio> #include &l ...
- 【Poj 1832】连环锁
连环锁 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1260 Accepted: 403 Description 许多 ...
- [BZOJ 2287/POJ openjudge1009/Luogu P4141] 消失之物
题面: 传送门:http://poj.openjudge.cn/practice/1009/ Solution DP+DP 首先,我们可以很轻松地求出所有物品都要的情况下的选择方案数,一个简单的满背包 ...
- 【POJ-2482】Stars in your window 线段树 + 扫描线
Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11706 Accepted: ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
随机推荐
- centos下安装redis(记录其中踩坑的过程)
一.先下载到redis-3.0.4.tar.gz包(本文以3.0.4版本为例) 我将这个包放在/opt目录下,在/opt下并解压这个包 tar -zxvf redis-.tar.gz 然后进入redi ...
- 如何系统学习并且掌握JavaScript
- 树莓派 -- oled 续(1) wiringPi
在上文中,分析了wiringPi 的oled demo是使用devfs来控制spi master和spi slave通讯. https://blog.csdn.net/feiwatson/articl ...
- 程序包javax.servlet.http不存在
在maven test项目时,出现错误: java:[7,26] 程序包javax.servlet.http不存在 原因:pom.xml中未引入javax.servlert-api相关的包 <d ...
- 洛谷 3871 [TJOI2010]中位数
[题解] 平衡树模板题,不过因为可以离线,所以有别的做法.把询问倒着做,变成删掉数字.求中位数,于是可以二分+树状数组. #include<cstdio> #include<cstr ...
- PID28 [Stupid]愚蠢的宠物
题链:https://www.rqnoj.cn/problem/28 题目描述 背景 大家都知道,sheep有两只可爱的宠物(一只叫神牛,一只叫神菜).有一天,sheep带着两只宠物到狗狗家时,这两只 ...
- es6(var,let,const,set,map,Array.from())
1.变量声明--var,const,let 1.1 var - (全局作用域,局部作用域)会有变量提升 //第一个小例子 <script> var num = 123; function ...
- MySQL workbench8.0 CE基本用法(创建数据库、创建表、创建用户、设置用户权限、创建SQL语句脚本)
原文地址:https://blog.csdn.net/zgcr654321/article/details/82156277 安装完成MySQL后,打开MySQL workbench8.0. 可以看到 ...
- 51nod 1010 只包含因子2 3 5的数 && poj - 1338 Ugly Numbers(打表)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 http://poj.org/problem?id=1338 首先 ...
- codevs——1275 有鱼的声音
1275 有鱼的声音 2012年CCC加拿大高中生信息学奥赛 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题解 查看运行结果 题目描述 Des ...