| ||||||||||
| 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 | |||||||||
Java实现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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator