Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication4
- {
- class myclass
- {
- float[,] m = new float[3, 3];
- public myclass() {}
- public myclass(float m11, float m12, float m13, float m21, float m22, float m23, float m31, float m32, float m33)
- {
- m[0, 0] = m11;
- m[0, 1] = m12;
- m[0, 2] = m13;
- m[1, 0] = m21;
- m[1, 1] = m22;
- m[1, 2] = m23;
- m[2, 0] = m31;
- m[2, 1] = m32;
- m[2, 2] = m33;
- }
- public float this[int a, int b]
- {
- get
- {
- return m[a, b];
- }
- set
- {
- m[a, b] = value;
- }
- }
- public static myclass operator *(myclass obj1, myclass obj2)
- {
- myclass res = new myclass();
- for (int row = 0; row < 3; row++)
- {
- for (int col = 0; col < 3; col++)
- {
- for (int inner = 0; inner < 3; inner++)
- {
- res[row, col] += obj1[row, inner] * obj2[inner, col];
- }
- }
- }
- return res;
- }
- public override string ToString()
- {
- for (int i = 0; i < 3; i++)
- {
- string str = "";
- for (int j = 0; j < 3; j++)
- {
- str = str + m[i, j].ToString() + "\t";
- }
- Console.WriteLine(str);
- }
- return "";
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- myclass obj1 = new myclass(1, 2, 3, 4, 5, 6, 7, 8, 9);
- myclass obj2 = new myclass(1, 2, 3, 4, 5, 6, 7, 8, 9);
- myclass mult = obj1 * obj2;
- Console.WriteLine(mult);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement