eric_dasini
发贴: 27
积分: 0
|
于 2004-09-29 15:42
import java.io.*;
class marry{ public static void main(String [] agrs) { char k=0; int i=0; int j=0; int u=0; System.out.print("Enter a int: "); try{ k =(char)System.in.read(); u=Integer.parseInt(String.valueOf); } catch(IOException e){}; int n = u; int m[][]=new int[n][n]; for(i=0;i<n;i++) for(j=0;j<n;j++){ if(i==j||i+j==(n-1)) m[i][j]=1; else m[i][j]=0; } System.out.println(n+"*"+n+"的阵列为"); System.out.println("---------------"); for(i=0;i<n;i++){ System.out.print("\n"); for(j=0;j<n;j++) System.out.print(" "+m[i][j]); }
} }
|