這是我第一次尋求編程幫助。任何人,我都需要編寫一個程序來查找矩陣的行列式(行列式代碼將在以後的日期)。問題在於我無法讓我的矩陣顯示。看起來我有正確寫入的數組,但輸出將跳過for循環寫入矩陣。是否會有任何需要改進的地方,或者如果我需要設置我的陣列來確定決定因素的某種方式?獲取矩陣顯示的問題
public class DetProg {
public static void main(String[] args) {
Scanner a = new Scanner (System.in);
Random mNum = new Random();
System.out.print("Enter matrix size: ");
int num = a.nextInt();
int numX = num;
int numY = num;
int [][] matNN = new int [numX] [numY];
int det = 0;// 0 is the placeholder until det method is inputted.
int n = mNum.nextInt(100)+1;
if (num >= 2)
{
for(int x = 0; x >= numX; x++)
{
for(int y = 0; y >= numY; y++)
{
matNN [x][y] = n;
System.out.println(matNN[x][y] + " ");
}
}
System.out.println("\n");
System.out.println("Determinant of a matrix is " + det);
}
else
System.out.println("Incorrect matrix size. Exiting...");
}
}
看看循環條件... –