恳请各位高手帮我看看

firedevil 2005-12-05 03:27:05
用JAVA编写矩阵程序,并要求矩阵的加减法
下面是我写的,问题多多
请给予斧正(另:请问如何调用Scheng()方法,生成矩阵)
import java.io.*;
public class Matrix
{
public void Scheng()
{
int[][] array=new int[3][3];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in), 1);
int i,j;
System.out.println("Please Insert the array elements");
for(i=0;i<2;i++)
for(j=0;j<2;j++)
{
array[i][j]=Integer.parseInt(br.readLine());

}
}
public void add( )
{
int i,j;
int[][] array1;
int[][] array2;
int[][] array3;
array3[i][j]=array1[i][j]+array[i][j];

}
public void subtraction( )
{
int i,j;
int[][] array1;
int[][] array2;
int[][] array3;
array3[i][j]=array1[i][j]-array[i][j];

}
}
...全文
88 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
believefym 2005-12-05
  • 打赏
  • 举报
回复
public class Matrix{
private int data[];
public Matrix(int rows,int columns){
//...
}

pubilc void add(int d2[][]){
//...
}

public void sub(int d2[][]){
//...
}

//...
}
firedevil 2005-12-05
  • 打赏
  • 举报
回复
汗个,那要怎么改
believefym 2005-12-05
  • 打赏
  • 举报
回复
楼主的程序根本不行
面向对象的思想也没有

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧