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

  1. Happy Joy Joy!
  2. http://icpc.baylor.edu/icpc/
  3. plain_vanilla
  4. (**)
  5. ?
  6. the 7% solution
  7. #

Sample Output

  1. Happy%20Joy%20Joy%21
  2. http://icpc.baylor.edu/icpc/
  3. plain_vanilla
  4. %28%2a%2a%29
  5. ?
  6. the%207%25%20solution

Source

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

  1. #include<stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. char str[80];
  6. while(gets(str) && strcmp(str, "#") != 0)
  7. {
  8. int i, len = strlen(str);
  9. for(i = 0; i < len; i++)
  10. {
  11. if(str[i] == ' ')
  12. printf("%%20");
  13. else if(str[i] == '!')
  14. printf("%%21");
  15. else if(str[i] == '$')
  16. printf("%%24");
  17. else if(str[i] == '%')
  18. printf("%%25");
  19. else if(str[i] == '(')
  20. printf("%%28");
  21. else if(str[i] == ')')
  22. printf("%%29");
  23. else if(str[i] == '*')
  24. printf("%%2a");
  25. else printf("%c",str[i]);
  26. }
  27. printf("\n");
  28. }
  29. return 0;
  30. }

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. 神经网络(NN)+反向传播算法(Backpropagation/BP)+交叉熵+softmax原理分析

    神经网络如何利用反向传播算法进行参数更新,加入交叉熵和softmax又会如何变化? 其中的数学原理分析:请点击这里.

  2. 12.Spring通过FactoryBean配置Bean

    为啥要使用FactoryBean: 在配置Bean的时候,需要用到IOC容器中的其它Bean,这个时候使用FactoryBean配置最合适. public class Car { private St ...

  3. ResNet实战

    目录 Res Block ResNet18 Out of memory # Resnet.py #!/usr/bin/env python # -*- coding:utf-8 -*- import ...

  4. Spider-Python爬虫之PyQuery基本用法

    1.安装方法 pip install pyquery 2.引用方法 from pyquery import PyQuery as pq 3.简介 pyquery 是类型jquery 的一个专供pyth ...

  5. codeforces 407 div1 A题(Functions again)

    codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on ...

  6. python——文件管理

    文件操作分为读.写.修改 一.读文件 f = open(file='D:/工作日常/兼职白领学生空姐模特护士联系方式.txt',mode='r',encoding='utf-8') data = f. ...

  7. Flask(1):基本示例、配置文件、路由、请求和响应、模板渲染

    Flask的特点: - pip install flask - 短小精悍.可扩展性强的 web框架 注意:上下文管理机制 - 依赖 wsgi:werkzeug Flask的简单示例: from fla ...

  8. 可持久化KMP

    一开始有一空串,n次操作,每次在串末尾加入一个字符问最小循环节.要求在线与可持久化. 如果只是在线的话那是很简单的,答案是!!$i-fail[i]$,其中$fail[i]$是KMP中的失配函数. 但如 ...

  9. PatentTips - Universal RAID Class Driver

    BACKGROUND OF THE INVENTION The present invention relates to the field of data storage devices. Comp ...

  10. VMware配置从U盘启动

    很遗憾,VMware的BIOS不能识别USB启动设备,即使已经把USB设备连接上去. 解决这一问题的做法是直接添加硬盘,硬盘指向物理硬盘,即USB设置. 注意:Ubuntu下要设置这一功能需要使用su ...