2010-03-05 34 views
2

C#程序從用戶輸入問一個2x2的整數矩陣的計算方法,並檢查2×2等於整數矩陣的計算C#幫助基本在矩陣的計算

+1

? – 2010-03-05 10:43:53

+0

@Jon,我想OP要我們爲他們寫...... X-)。當然,似乎Homewrok ... – 2010-03-05 10:56:37

+0

是的,我需要幫助寫它,它從C的練習本,但我需要在C# – Kai 2010-03-05 11:01:39

回答

1

您必須確定要如何輸入自己匹配的矩陣。例如,你可以像這樣提示。請注意,可能有很多更好的方法來做到這一點,但這將完成工作。我想這是你要求的。

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

命名空間ConsoleApplication2

{

class Program 

{ 

    static void Main(string[] args) 

    { 

     Console.WriteLine("Enter element at 0,0:"); 

     string m00 = Console.ReadLine(); 

     Console.WriteLine("Enter element at 0,1:"); 

     string m01 = Console.ReadLine(); 

     Console.WriteLine("Enter element at 1,0:"); 

     string m10 = Console.ReadLine(); 

     Console.WriteLine("Enter element at 1,1:"); 

     string m11 = Console.ReadLine(); 


     int[,] inputMatrix = new int[ 2, 2 ]; 

     inputMatrix[ 0, 0 ] = int.Parse(m00); 
     inputMatrix[ 0, 1 ] = int.Parse(m01); 
     inputMatrix[ 1, 0 ] = int.Parse(m10); 
     inputMatrix[ 1, 1 ] = int.Parse(m11); 


    } 

} 

}位都被你遇到的麻煩哪位