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. Update与FixedUpdate区别

    以下的代码能使游戏暂停,记得要使速度*Time.deltaTime,目的是保证游戏运行在帧数不同的情况下,角色移动速度都一样,因为此时角色是按时间移动与帧数无关. using UnityEngine; ...

  2. Python 正则表达式指南 zz

    zz http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html 1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一 ...

  3. SQL多条件查询安全高效比较

    ALTER PROCEDURE _tmp @ID VARCHAR(50), @PN VARCHAR(50), @Type INT AS BEGIN /************************* ...

  4. mysql 实现行号的方法——如何获取当前记录所在行号

    SELECT aaa,(@rowNum:=@rowNum+1) AS rowNoFROM tb_bbb,(SELECT (@rowNum :=0) ) bORDER BY tb_bbb.liushui ...

  5. [HDOJ3308]LCIS(线段树,区间合并)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 题意:给定n个数,两个操作: U A B:将位置A的数值改成B Q A B:查询[A,B]内最长 ...

  6. VEP安装指南

    #下载依赖包 sudo apt-get install -y curl rsync tar make perl perl-base tabix #设置perl环境变量 export PERL_PATH ...

  7. PE结构笔记

    提示:前面加*为必须背下来的 DOS头: typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header WORD e_magic; //* Magic n ...

  8. 分区格式化mkfs

    mkfs —  build a Linux filesystem 用法举例: mkfs.ext3  /dev/sdb1 #把sdb1格式化为ext3文件系统 也可以写成 mkfs -t ext3 /d ...

  9. IO设计模式:Reactor和Proactor对比

    IO设计模式:Reactor和Proactor对比 平时接触的开源产品如Redis.ACE,事件模型都使用的Reactor模式:而同样做事件处理的Proactor,由于操作系统的原因,相关的开源产品也 ...

  10. C++中的一些定义

    PS: 这篇博客用来记录一些一般的C++书中草草掠过的一些概念. 或者一些不太容易理解的概念的详细解释. 欢迎新手进入,欢迎高手指正! Orz . 引用: 为对象起了另外一个名字, 引用类型引用(re ...