Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Matrix
- {
- double[] matrix;
- int col;
- int row;
- public Matrix(int row,int col)
- {
- this.row = row;
- this.col = col;
- matrix = new double[row * col];
- }
- public int Width { get { return col; } }
- public int Height { get { return row; } }
- public double this[int row,int col]
- {
- get { return matrix[row * Width + col]; }
- set { matrix[row * Width + col] = value; }
- }
- public override string ToString()
- {
- StringBuilder builder = new StringBuilder();
- for(int i = 0; i < Width;i++)
- {
- for(int j = 0;j < Height;j++)
- {
- builder.AppendFormat("{0}\t",this[i,j]);
- }
- builder.AppendLine();
- }
- return builder.ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement