zoj 2932 The Seven Percent Solution
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.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
#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的更多相关文章
- HDUOJ-------2719The Seven Percent Solution
The Seven Percent Solution Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- POJ 3650:The Seven Percent Solution
The Seven Percent Solution Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7684 Accep ...
- 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 ...
- Nodejs - 如何用 eventproxy 模块控制并发
本文目标 本文的目标是获取 ZOJ 1001-1010 每道题 best solution 的作者 id,取得数据后一次性输出在控制台. 前文 如何用 Nodejs 分析一个简单页面 我们讲了如何用 ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- ZOJ Monthly, March 2018 Solution
A - Easy Number Game 水. #include <bits/stdc++.h> using namespace std; #define ll long long #de ...
- ZOJ Monthly, January 2018 Solution
A - Candy Game 水. #include <bits/stdc++.h> using namespace std; #define N 1010 int t, n; int a ...
随机推荐
- 动手实现 React-redux(二):结合 context 和 store
既然要把 store 和 context 结合起来,我们就先构建 store.在 src/index.js 加入之前创建的 createStore 函数,并且构建一个 themeReducer 来生成 ...
- AJPFX对选择和冒泡两种排序的理解
冒泡排序和直接选择排序都是排序中比较简单和容易实现的算法,先简单说说两者的区别:先以按照元素从小到大为:冒泡排序:将相邻元素两两比较,如果有比较大的,就把比较大的放在右边,这样的结果就是一轮排序完毕后 ...
- ImageView控件
ImageView 显示图片 常用属性: src 要显示的图片 foreground 前景图 backgrund 背景图 alpha 透明度 clickable 是否可以点击 onClick ...
- 【转】码云source tree 提交超过100m 为什么大文件推不上去
码云source tree 提交超过100m 为什么大文件推不上去 2017年01月12日 16:50:51 阅读数:7634 git -c diff.mnemonicprefix=false -c ...
- 各 Android 平台版本支持的 API 级别
平台版本 API 级别 VERSION_CODE 备注 Android 7.0 24 N 平台亮点 Android 6.0 23 M 平台亮点 Android 5.1 22 LOLLIPOP_MR1 ...
- IOS访问webserver接口
接口调用参数只能是字符串格式,返回格式支持3种(字符串,数组,DataSet) 需要引用第三方库,包含(DataSet,PlatServinceDataParser,WebserviceCommon, ...
- python中的seteuid
seteuid(...) seteuid(uid) Set the current process's effective user id.
- 【持续更新】把.net代码转换为java代码的注意事项
国内大多数大学的软件相关专业大多强制学生学习c和Java,但.net 的几个语言可以说是选学的. 由于visual studio在windows平台上使用相对方便,一些同学会在上大学的Java课之前自 ...
- 查看cuda版本和cudann
nvcc -V 没有找到直接查询cudann版本的命令,但发现cudann装在 /usr/local/cuda/lib64/目录下,libcudnn.so就是相应版本
- python小随笔
关于pip安装 .\pip.exe install --ignore-installed --upgrade tensorflow-gpu python可视化库 Seaborn:是一个基于matplo ...