我想在1个程序中编写2个矩阵,但它没有答案? [英] i want to write 2 matrix in 1 program but it doesnt answer?
本文介绍了我想在1个程序中编写2个矩阵,但它没有答案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<pre lang="cs">package matrix;
import java.util.Scanner;
public class Main {
private static Object numbers;
public static void main(String[] args) {
System.out.print("enter number for rows: ");
Scanner in=new Scanner(System.in);
int rows=in.nextInt();
System.out.print("enter number for columns: ");
int column=in.nextInt();
int[][] a=new int[rows][column];
int[][] b=new int[rows][column];
for(int i=0;i<rows;i++){
for(int j=0;j<column;j++){
System.out.printf("enter numbers["+i+"],["+j+"]: ");
int length1=in.nextInt();
// a[i][j]=in.nextInt();
System.out.printf(" ");
System.out.print("enter number for rows: ");
int rows1=in.nextInt();
System.out.print("enter number for columns: ");
int column1=in.nextInt();
int[][] c=new int[rows][column];
int[][] d=new int[rows][column];
for(int k=0;k<rows1;k++){
for(int l=0;l<column1;l++){
System.out.printf("enter numbers["+k+"],["+l+"]: ");
int length2=in.nextInt();
// a[i][j]=in.nextInt();
System.out.printf(" ");
}
}
}
}
}
}
推荐答案
如果您告诉代码这样做,则可以让用户输入该数字!为什么将a [i] [j]分配给行和列?您应该将扫描的值分配给a [i] [j].
you can let the user give the number if you tell the code to do so !!! why are assigning a[i][j] to rows and column????? you should assign the scanned value to a[i][j].
这篇关于我想在1个程序中编写2个矩阵,但它没有答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文