源代码:
public static void main(String[] args) {
// TODO 自动生成的方法存根
char [][]a=new char[4][];
a[0]=new char[] {'春','眠','不','觉','晓'};
a[1]=new char[] {'处','处','闻','啼','鸟'};
a[2]=new char[] {'夜','来','风','雨','声'};
a[3]=new char[] {'花','落','知','多','少'};
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(a[i][j]);
}
if (i==0) {
System.out.println(",");
} else {
System.out.println("。");
}
}//横版
System.out.println("------------------");
for (int j = 0; j < 5; j++) {
for (int i = 3; i >= 0; i--) {
System.out.print(a[i][j]);
}System.out.println("");
}System.out.print("。,。,");
//竖版
}
结果示例:
吾独矣
终极愿望世界和平