L
Lain
Gast
Ich möchte ein Matrix programm schreiben bzw. meine Pflicht ist es ein zu schreiben.
Das verschieden große Matrixfelder erstellt,
erst soll gefragt werden wie groß die Matrix sein soll (das müsste ich soweit haben, mit den spalten und zeilen).
Nun weiß ich nicht wie ich die matrix schreiben soll.
Also die zeilen und spalten.
(5)
Z.B bei einer matrix[0][2] -> a (7)
(0)
wie schreibe / speicher ich die zahlen ab?
[/code]
Das verschieden große Matrixfelder erstellt,
erst soll gefragt werden wie groß die Matrix sein soll (das müsste ich soweit haben, mit den spalten und zeilen).
Nun weiß ich nicht wie ich die matrix schreiben soll.
Also die zeilen und spalten.
(5)
Z.B bei einer matrix[0][2] -> a (7)
(0)
wie schreibe / speicher ich die zahlen ab?
Code:
import java.util.*;
class Matrix {
static int x, y; //important, because you have to read the matrix
static String s; //important, because my InteractivIO wants a STRING!
static double [][]matrix; //important for the matrix (2dimensions [m=rows][n=coloms])
//----------------------------------------------------------------------------------------------
Matrix (int m, int n)throws Exception { //create a M-by-N matrix
x=m;
y=n;
matrix = new double [m][n];
}
//--------------------------------------------------------------------------------------------
public String toString() {
printMatrix(matrix);
return s;
}
public void printMatrix(double [][]matrix){
int m = matrix.length; //Rows
System.out.println();
for(int i=0; i<m; i++){
int n = matrix[i].length;
System.out.print("[ ");
for(int j=0; j<n; j++){
System.out.print(matrix[i][j]+" ");
}
System.out.println("]");
}
}
//--------------------------------------------------------------------------------------------
public void setElement(int i, int j, double k){
}
public void getElement(int i, int j){
}
public void add (Matrix mat){
}
public void multiply(Matrix mat){
}
//--------------------------------------------------------------------------------------------
public static void main (String[]args) throws Exception {
Matrix A,B; //for the matrix
Matrix C; //for addition and multiplication, result matrix
A= new Matrix(x,y);
B= new Matrix(x,y);
C= new Matrix(x,y);
InteractivIO.write("Please write the demnision of the matrix, Coloumn and Rows");
y=InteractivIO.readInt("Colomns: ");
x=InteractivIO.readInt("Rows: ");
InteractivIO.write("Please write the unkonws in the first coloumn");
A.toString();
B.toString();
C.toString();
}
}//end