简体   繁体   English

Matrice中的C#帮助基础

[英]C# Help Basic in Matrice

向用户询问的C#程序输入2x2整数矩阵并检查2x2是否等于整数矩阵

You have to determine how you want the input to match the matrix yourself. 您必须确定自己希望输入如何与矩阵匹配。 For example, you can prompt like this. 例如,您可以这样提示。 Please note there are probably many better ways to do this, but this will get the job done. 请注意,可能有许多更好的方法可以做到这一点,但这可以完成工作。 I think this is what you're asking for. 我想这就是您要的。

using System; 使用系统;

using System.Collections.Generic; 使用System.Collections.Generic;

using System.Linq; 使用System.Linq;

using System.Text; 使用System.Text;

namespace ConsoleApplication2 命名空间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 );


    }

}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM