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 ...
随机推荐
- CentOS7-wget命令
Wget主要用于下载文件,在安装软件时会经常用到,以下对wget做简单说明.转载自:https://www.cnblogs.com/lxz88/p/6278268.html 1.下载单个文件:wget ...
- luogu4388 付公主的矩形
题面: 为了排解心中的怒气,她造了大量的稻草人来发泄.每天付公主都会把一些稻草人摆成一个R∗C的矩形,矩形的每个方格上都有一个稻草人.然后她站在这个矩形的左上角,向矩形的右下角射箭.付公主的箭术过人, ...
- [0] Hello World
受不了CSDN了,广告多,慢,编辑器难用,还限制博客数量.
- laravel学习笔记1--基础
一.安装 1.安装 composer create-project laravel/laravel=v5.5.28 laravel 2.测试 配置nginx根目录为laravel/public,并且美 ...
- 【02】emmet系列之HTML语法
[01]emmet系列之基础介绍 [02]emmet系列之HTML语法 [03]emmet系列之CSS语法 [04]emmet系列之编辑器 [05]emmet系列之各种缩写 初始化 :快速编写HTML ...
- 如何判断CPU、内存、磁盘的性能瓶颈?
1.如何判断CPU.内存.磁盘的瓶颈? CPU瓶颈1) 查看CPU利用率.建议CPU指标如下 a) User Time:65%-70% b) System Time:30%-35% c) Idle:0 ...
- JavaScript学习---简易图片轮播
效果如下: 图片定时轮播 点击左右控制显示下一张或上一张图片 index.html文件 <html> <head> <title> js编写实现幻灯片效果 < ...
- hdu 1698区间延迟更新
#include<stdio.h> #define N 100100 struct node { int x,y,yanchi; }a[N*4];//注意数组范围 void build(i ...
- spring-session(一)揭秘
前言 在开始spring-session揭秘之前,先做下热脑(活动活动脑子)运动.主要从以下三个方面进行热脑: 为什么要spring-session 比较traditional-session方案和s ...
- HDU——3342 Legal or Not
Legal or Not Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...