gpt4 book ai didi

C# Help Basic in 矩阵

转载 作者:太空宇宙 更新时间:2023-11-03 14:32:00 27 4
gpt4 key购买 nike

C# 程序要求用户输入一个 2x2 整数矩阵并检查 2x2 是否等于整数矩阵

最佳答案

您必须自己确定输入与矩阵的匹配方式。比如你可以这样提示。请注意,可能有许多更好的方法可以做到这一点,但这将完成工作。我认为这就是您的要求。

使用系统;

使用 System.Collections.Generic;

使用 System.Linq;

使用系统文本;

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


}

}

关于C# Help Basic in 矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2386053/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com