您的位置:首页 > 其它

PKU_ACM_3650_The Seven Percent Solution

2008-11-06 11:59 399 查看
http://acm.pku.edu.cn/JudgeOnline/problem?id=3650 原题

简单题

import java.io.*;

import java.util.*;

public class Main

{

static HashMap<String,String> code;

public static void main(String[] args) throws Exception

{

initMap();

readFile();

}

public static void readFile() throws Exception

{

BufferedReader br = new BufferedReader(

new InputStreamReader(System.in));

String dest = null;

while(!(dest=br.readLine()).equals("#"))

process(dest);

}

public static void initMap()

{

code = new HashMap<String,String>();

code.put(" ","%20");

code.put("!","%21");

code.put("$","%24");

code.put("%","%25");

code.put("(","%28");

code.put(")","%29");

code.put("!","%21");

code.put("*","%2a");

}

public static void process(String dest)

{

StringBuffer ret = new StringBuffer();

String temp = null;

String temp2 = null;

for(int i=0; i<dest.length(); i++)

{

temp = dest.charAt(i)+"";

if((temp2=code.get(temp))==null)

{

ret.append(temp);

}

else

{

ret.append(temp2);

}

}

System.out.println(ret.toString());

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: