| ||||||||||
| 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:这题实在不知道为何RE?官方数据都通过了,也考虑了数据之间有多个空格,求教(付程序) Posted by:fame at 2004-05-03 13:34:44 > import java.io.*;
> import java.util.*;
> import java.math.*;
> public class Main{
> static int[] k = new int[3];
> public static void main(String[] args) throws Exception{
> BufferedReader stdin =
> new BufferedReader(
> new InputStreamReader(System.in));
> while(true){
> String s = stdin.readLine();
> StringTokenizer st = new StringTokenizer (s, " ");
> String[] ks = s.split(" ");
> int i = 0;
> while(st.hasMoreTokens()){
> String temp = st.nextToken();
> if(temp.equals(""))
> continue;
> k[i] = Integer.parseInt(temp);
> i++;
> }
> if(k[0] == 0 && k[1] == 0 && k[2] == 0)
> return;
> doit(stdin.readLine());
> //doit(m);
> }
> }
> private static void doit(String en){
> String[][] g1 = new String[en.length()][2];
> String[][] g2 = new String[en.length()][2];
> String[][] g3 = new String[en.length()][2];
> int ind1 = 0;
> int ind2 = 0;
> int ind3 = 0;
> for(int i = 0; i < en.length(); i++){
> if(en.charAt(i)>='a' && en.charAt(i) <='i'){
> g1[ind1][0] = en.charAt(i)+"";
> g1[ind1][1] = i+"";
> ind1++;
> }
> else if(en.charAt(i)>='j' && en.charAt(i) <='r'){
> g2[ind2][0] = en.charAt(i)+"";
> g2[ind2][1] = i+"";
> ind2++;
> }
> else{
> g3[ind3][0] = en.charAt(i)+"";
> g3[ind3][1] = i+"";
> ind3++;
> }
> }
> String[] result = new String[en.length()];
> String[][] g11 = new String[ind1][2];
> for(int i = 0; i < ind1; i++){
> g11[(i+k[0])%ind1][0] = g1[i][0];
> g11[i][1] = g1[i][1];
> }
> for(int i = 0; i < ind1; i++)
> result[Integer.parseInt(g11[i][1])] = g11[i][0];
>
> String[][] g22 = new String[ind2][2];
> for(int i = 0; i < ind2; i++){
> g22[(i+k[1])%ind2][0] = g2[i][0];
> g22[i][1] = g2[i][1];
> }
> for(int i = 0; i < ind2; i++)
> result[Integer.parseInt(g22[i][1])] = g22[i][0];
>
> String[][] g33 = new String[ind3][2];
> for(int i = 0; i < ind3; i++){
> g33[(i+k[2])%ind3][0] = g3[i][0];
> g33[i][1] = g3[i][1];
> }
> for(int i = 0; i < ind3; i++)
> result[Integer.parseInt(g33[i][1])] = g33[i][0];
> for(int i = 0; i < en.length(); i++)
> System.out.print(result[i]);
> System.out.println();
>
>
> }
>
> }
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator