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.orgftp://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的更多相关文章

  1. HDUOJ-------2719The Seven Percent Solution

    The Seven Percent Solution Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  2. zoj 2932 The Seven Percent Solution

    The Seven Percent Solution Time Limit: 2 Seconds      Memory Limit: 65536 KB Uniform Resource Identi ...

  3. The Seven Percent Solution

    Problem Description Uniform Resource Identifiers (or URIs) are strings like http://icpc.baylor.edu/i ...

  4. HDU 2719 The Seven Percent Solution

    #include <cstdio> #include <cstring> int main() { ]; ]!='#') { ; while (i<strlen(s)) ...

  5. HDU 2719 The Seven Percent Solution (水题。。。)

    题意:把字符串中的一些特殊符号用给定的字符串代替. 析:没的说. 代码如下: #include <iostream> #include <cstdio> #include &l ...

  6. 【Poj 1832】连环锁

    连环锁 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1260   Accepted: 403 Description 许多 ...

  7. [BZOJ 2287/POJ openjudge1009/Luogu P4141] 消失之物

    题面: 传送门:http://poj.openjudge.cn/practice/1009/ Solution DP+DP 首先,我们可以很轻松地求出所有物品都要的情况下的选择方案数,一个简单的满背包 ...

  8. 【POJ-2482】Stars in your window 线段树 + 扫描线

    Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted:  ...

  9. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

随机推荐

  1. 初识Python(windows)——下载、安装、使用

    Table of Contents 1. Why is Python 1.1. Python和R 2. python的下载与安装 2.1. python的版本选择 2.2. python的下载 2.3 ...

  2. java中引用对比C++指针

    前置知识地址:https://blog.csdn.net/wangfei8348/article/details/51383805 重点在后面的引用对比实验(测试出内存地址,我很开心哈哈哈,客观给个好 ...

  3. nodejs学习(二) ---- express中使用模板引擎jade

    系列教程,上一节教程  express+nodejs快速创建一个项目 在创建一个项目后,views目录下的文件后缀为 .jade . 打开 index.jade,具体内容如下图(忽略 header.j ...

  4. laravel学习笔记3--高级

    一.artisan 1.基本使用: 1.1.查看基本命令: php artisan 1.2.查看具体命名的使用: php artisan help migrate 1.3.创建控制器: php art ...

  5. ruby 第五次作业 part 1(分类、排序)

    movies_controller.rb class MoviesController < ApplicationController def movie_params params.requi ...

  6. Android Studio + Genymotion模拟器安装与配置

    一.Android studio 下载与安装 https://developer.android.google.cn/studio/index.html 进入谷歌官方链接下载Android studi ...

  7. Linux 搭建 squid 代理服务器 三种模式

    CentOS 6.7 squid 代理服务器 一般有两张或以上网卡,一张链接公网,访问外网资源,一张位于局域网. 代理服务器可以提供文件缓存.复制和地址过滤等服务,充分利用有限的出口带宽,加快内部主机 ...

  8. [bzoj3531][Sdoi2014][旅行] (主席树+树链剖分)

    Description S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天面条神教.隐形独角兽教.绝地教都是常见的信仰. ...

  9. STM32F407 开发环境搭建 程序下载 个人笔记

    详细资料: http://www.openedv.com/thread-13912-1-1.html 需要安装的软件: 1.keil(MDK,必选),用keygen破解 2.CH340驱动,(usb串 ...

  10. mysql 判断索引是否存在,存在则删除再创建索引(分表) 存储过程

    1.分表5数据量大,执行所有分表修改,不包括5 CREATE PROCEDURE deleteIndex()BEGINDECLARE corpId CHAR (16);DECLARE flag INT ...