The Seven Percent Solution

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1680    Accepted Submission(s): 1215

Problem 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–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>
#include<stdlib.h>
#define maxn 101
char str[maxn];
int main()
{
while(gets(str)!=NULL&&str[]!='#')
{
for(int i=;i<strlen(str);i++)
{
if(str[i]==' ') printf("%%20");
else if(str[i]=='$')printf("%%24");
else if(str[i]=='!')printf("%%21");
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]);
}
putchar();
}
return ;
}

HDUOJ-------2719The Seven Percent Solution的更多相关文章

  1. zoj 2932 The Seven Percent Solution

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

  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. HDU题解索引

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

  7. C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...

  8. C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...

  9. Enterprise Solution 3.1 企业应用开发框架 .NET ERP/CRM/MIS 开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    行业:基于数据库的制造行业管理软件,包含ERP.MRP.CRM.MIS.MES等企业管理软件 数据库平台:SQL Server 2005或以上 系统架构:C/S 开发技术 序号 领域 技术 1 数据库 ...

随机推荐

  1. [转]Unity3D协程介绍 以及 使用

    作者ChevyRay ,2013年9月28日,snaker7译  原文地址:http://unitypatterns.com/introduction-to-coroutines/ 在Unity中,协 ...

  2. return、 return false的用法

    1. return返回null,起到中断方法执行的效果,只要不return false事件处理函数将会继续执行,表单将提交2. return false,事件处理函数会取消事件,不再继续向下执行.比如 ...

  3. Android获取窗体信息的Util方法

    package com.wangyi.tools; import android.app.Activity; import android.util.DisplayMetrics; public cl ...

  4. vector的插入、lower_bound、upper_bound、equal_range实例

    对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...

  5. 键盘ctrl+shift不能切换输入法

    1.首先检查输入法是否被卸载,如没被卸载: 2.使用下面如图方法进行设置

  6. fFFmpeg 命令、案例、测试集中营

    gitbook: https://www.gitbook.com/book/xdsnet/other-doc-cn-ffmpeg/details ffmpeg [全局选项] {[输入文件选项] -i ...

  7. 播放列表文件用于HTTP实时流的使用

    广告播放清单(Discontinuities): 通常你会想要提供一系列的电影,在每个电影前面显示一些品牌(广告),让用户知道这些电影来自你的特定网站.一种方法是简单地将广告与每部电影合并.但是如果你 ...

  8. 优秀c++开源项目集合

    本文会持续更新, 我希望通过这篇文章把我看到过的优秀开源项目记录下来, 有时间仔细阅读. cockroachdb 前googler开发的开源的spanner数据库: https://github.co ...

  9. nodejs学习笔记<二>简单的node服务器

    在环境搭建好后,就可以开始动手架设(node驱动)一个简单的web服务器. 首先,nodejs还是用js编写.先来看一段node官网上的实例代码. var http = require('http') ...

  10. golang编码转换

    在网上搜索golang编码转化时,我们经常看到的文章是使用下面一些第三方库: https://github.com/djimenez/iconv-go https://github.com/qiniu ...