Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
交流一下代码,很久以前的了,效率不高。In Reply To:AC的代码,与喜欢java的朋友一起切磋! Posted by:Jin_j_y at 2004-10-25 11:49:10 import java.io.*; import java.util.*; class Main{ public static void main(String [] args)throws IOException{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); String str; String g[]={"abcdefghi","jklmnopqr","stuvwxyz_"}; while (!(str=in.readLine().trim()).equals("0 0 0")){ StringTokenizer st=new StringTokenizer(str," "); int k[]=new int[3]; for (int i=0;i<3;i++){ k[i]=Integer.parseInt(st.nextToken()); } StringBuffer str1=new StringBuffer(in.readLine()); int n=str1.length(); for (int b=0;b<3;b++){ StringBuffer tmp=new StringBuffer(); for (int i=0;i<n;i++){ char ch=str1.charAt(i); if (g[b].indexOf(ch)>-1){ tmp.append(ch); str1.setCharAt(i,' '); } } int nx=tmp.length(); if (nx>0){ for (int i=0;i<k[b];i++){ tmp.insert(0,tmp.charAt(nx-1)); tmp.deleteCharAt(nx); } int j=0; for (int i=0;i<n;i++){ if (str1.charAt(i)==' '){ str1.setCharAt(i,tmp.charAt(j)); j++; } } } } System.out.println(str1); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator