Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Java实现

Posted by Hammer307 at 2009-12-13 02:09:30
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		int rows = 0;
		int cols = 0;
		String str = null;
		
		Scanner cin = new Scanner(System.in);
		
		while(cin.hasNext()){
			cols = cin.nextInt();
			if(cols == 0) break;
			str = cin.next();
			rows=str.length()/cols;
			char[][] a = new char[rows][cols];
			for(int i = 0; i < rows; i++){
				for(int j=0; j < cols; j++){
					
					if(i%2 == 0)
						a[i][j] = str.charAt(i*cols+j);		
					else
						a[i][j] = str.charAt((i+1)*cols-1-j);		
				}
			}	
			for(int j=0; j < cols; j++)
				for(int i = 0; i < rows; i++)
					System.out.print(a[i][j]);
			System.out.println();
		}
	}

}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator