博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SDNU 1059.The Seven Percent Solution(水题)
阅读量:7216 次
发布时间:2019-06-29

本文共 2055 字,大约阅读时间需要 6 分钟。

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–1000 characters long and on a line by itself, followed by a line containing only "#" that signals the end of 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%21http://icpc.baylor.edu/icpc/plain_vanilla%28%2a%2a%29?the%207%25%20solution
#include 
#include
#include
#include
#include
#include
#include
using namespace std;#define ll long longstring s;int main(){ while(getline(cin, s) && s != "#") { int len = s.size(); for(int i = 0; i

 

转载于:https://www.cnblogs.com/RootVount/p/10889807.html

你可能感兴趣的文章
MySQL 5.7中的更多改进,包括计算列
查看>>
书评与访谈:Scrum for Managers
查看>>
借助Unity AR Foundation构建跨平台AR应用
查看>>
《The Coaching Booster》问与答
查看>>
独立云计算服务商的多维实践之道:用户需求驱动变革
查看>>
JavaMail邮件发送不成功的那些坑人情况及分析说明
查看>>
GitHub Checks API帮助应用实现进一步的持续集成
查看>>
庖丁解牛迭代器,聊聊那些藏在幕后的秘密
查看>>
勇敢的交流者在敏捷组织中的重要性
查看>>
Android Pie提供了自适应供电、神经网络API 1.1等新特性
查看>>
蓝云公布2019云生态战略,如何解决企业上云关键问题?
查看>>
FaaS、PaaS和无服务器体系结构的优势
查看>>
Ceylon语言加入Eclipse基金会
查看>>
一文盘点MWC 2019所有5G设备和研发进展
查看>>
【leetcode】85. Maximal Rectangle 0/1矩阵的最大全1子矩阵
查看>>
网站真分页js代码该怎么写?
查看>>
教你五分钟入门使用html5 svg绘制图形
查看>>
vue-concise-slider vue滑动组件
查看>>
ElectronOCR:基于Electron+React+Tesseract的MACOS下的OCR工具
查看>>
Mysql 架构及优化之-定时计划任务
查看>>