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());
}
}
简单题
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());
}
}
相关文章推荐
- poj 3650 The Seven Percent Solution
- POJ 3650:The Seven Percent Solution
- POJ 3650 && HDU 2719 The Seven Percent Solution(水~)
- poj 3650 The Seven Percent Solution
- poj 3650 The Seven Percent Solution
- POJ 3650 The Seven Percent Solution
- POJ 3650 The Seven Percent Solution
- poj 3650 The Seven Percent Solution
- ACM--steps--dyx--1.2.5--The Seven Percent Solution
- 杭电ACM2719——The Seven Percent Solution
- 「HD_ACM」The Seven Percent Solution
- POJ 3650 The Seven Percent Solution
- 杭电 acm The Seven Percent Solution
- POJ 3650 & ZJU 2932 & HDU 2719 The Seven Percent Solution(模拟)
- ZOJ Problem Set - 2932 The Seven Percent Solution
- zoj 2932 The Seven Percent Solution
- The Seven Percent Solution
- The Seven Percent Solution
- The Seven Percent Solution
- HDU The Seven Percent Solution [Ad Hoc]