The Seven Percent Solution


Time Limit: 2 Seconds      Memory Limit: 65536 KB

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
 #include <iostream>
#include <cstdio>
#include <string>
using namespace std; void judge(char c){
switch(c){
case ' ': cout << "%20"; break;
case '!': cout << "%21"; break;
case '$': cout << "%24"; break;
case '%': cout << "%25"; break;
case '(': cout << "%28"; break;
case ')': cout << "%29"; break;
case '*': cout << "%2a"; break;
default: cout << c; break;
}
} int main(){
string s;
while(getline(cin, s)){
if(s[] == '#')
break;
int len = s.length();
for(int i = ; i < len; i++)
judge(s[i]);
cout << endl;
}
//system("pause");
return ;
}
 

zoj 2932 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. POJ 3650:The Seven Percent Solution

    The Seven Percent Solution Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7684   Accep ...

  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. Nodejs - 如何用 eventproxy 模块控制并发

    本文目标 本文的目标是获取 ZOJ 1001-1010 每道题 best solution 的作者 id,取得数据后一次性输出在控制台. 前文 如何用 Nodejs 分析一个简单页面 我们讲了如何用 ...

  7. HDU题解索引

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

  8. ZOJ Monthly, March 2018 Solution

    A - Easy Number Game 水. #include <bits/stdc++.h> using namespace std; #define ll long long #de ...

  9. ZOJ Monthly, January 2018 Solution

    A - Candy Game 水. #include <bits/stdc++.h> using namespace std; #define N 1010 int t, n; int a ...

随机推荐

  1. 在CATIA中通过OUTGEN 生成OUT 文件 教程

    前言: 本教程基于CATIA V5R2014版本. 关于大众数据标准格式:OUT/DMU/PCA文件的说明,如图1所示. 图1:关于OUT/DMU/PCA文件的说明 1.创建KPR文件,下挂所有子文件 ...

  2. magento package

    Magento Local module file is relative to app/code/local/ Magento Community module file is relative t ...

  3. 什么是Servlet容器?(分析很到位)

    在本文中,我写了一些关于Web服务器.Servlet容器以及它与JVM的关系的基本概念.我想表达的是,Servlet容器也仅仅不过是一个Java程序. 1. 什么是Web服务器? 想要知道什么是Ser ...

  4. HTML5实现页面自动跳转

    初学H5,书上说的是<meta http-equiv="refresh" content="5“ url=”./error.html"/>这样可以实 ...

  5. ionic back 返回按钮不正常显示&&二级路由点击返回按钮失效无法返回到上一级页面的问题

    很多时候,app不只有一两级路由,还要三四级路由,但是在ionic中,给出的返回键三级或四级无法使用,所以得自定义方法设置返回. 直接贴代码: <ion-nav-buttons side=&qu ...

  6. 项目适配iOS9遇到的一些问题及解决办法 ,以及URL 白名单配置方法

    1.网络请求报错.升级Xcode 7.0发现网络访问失败.输出错误信息 The resource could not be loaded because the App Transport Secur ...

  7. FPGA原型验证

    为什么要做FPGA原型验证? FPGA原型验证可以在IC流片前对芯片功能和性能做出评估,同时,可以给软件设计人员提供验证平台.所有的设计,无论是SOC还是ASIC都需要被验证(功能和时序验证),以确保 ...

  8. HTTP 方法:GET 对比 POST 转自w3school

    两种最常用的 HTTP 方法是:GET 和 POST. 什么是 HTTP? 超文本传输协议(HTTP)的设计目的是保证客户机与服务器之间的通信. HTTP 的工作方式是客户机与服务器之间的请求-应答协 ...

  9. IDEA一些设置

    1. 设置字体为Consolas,Size:16, Line spacing: 1.1 2. 设置智能提示大小写不敏感 在设置中搜索sense, 找到配置节点 Editor->General-& ...

  10. Docker下redis的主从配置

    1.拉取redis镜像docker pull redis2.启动3个redis容器服务,分别使用到6379.6380.6381端口docker run --name redis-6379 -p 637 ...