C#init数组

扫码查看
} public static void AddMatrix(int [,] array1,int [,] array2,int [,] array3) { for(int row = 0;行< array1.GetLength(0);行++) { for(int column = 0; column< array1.GetLength(1); column ++) array3 [row,column] = array1 [row,column] + array2 [row,column]; } for(int row = 0; row< array1.GetLength(0); row ++) { for( int column = 0; column< array1.GetLength(1); column ++) Console.Write(" {0}",array3 [row,column] ]); } Console.WriteLine(); } public static void SubtractMatrix(int [,] array1,int [,] array2,int [,] array3) { for(int row = 0; row< array1.GetLength(0); row ++) { for(int column = 0; column< array1.GetLength(1); column ++) array3 [row,column] = array1 [row,column] - array2 [row,专栏]; } for(int row = 0; row< array1.GetLength (0);行++) { for(int column = 0; column< array1.GetLength(1); column ++) Console.Write(" {0}",array3 [row,column]); } Console.WriteLine(); } } {/ CODE }I''''m working on a project that will add,multipy,subtract and divide a matrix. Each one is suppose to be display in a method. I can figure out the addition and subtraction but not the multipication and divison. I also needs help with user input. The user suppose to enter the values in the Display Method, but I''m having trouble with the Console.Intt32. My code is below. [code]using System;public class Matrix{public static void Main(string[] args){int[,] matrix1 = { {1, 2 }, { 3, 4 } };int[,] matrix2 = { { 2, 3 }, { 4, 5 } };int[,] matrix3 = new int [2,2];DisplayMatrix(matrix1);Console.WriteLine();DisplayMatrix(matrix2);AddMatrix(matrix1, matrix2, matrix3);SubtractMatrix(matrix1, matrix2, matrix3);}public static void DisplayMatrix(int[,] array){for (int row=0; row < array.GetLength(0); row++){for (int column = 0; column < array.GetLength(1); column++)array=Convert.ToInt(Console.ReadLine());Console.Write("{0}", array[ row, column]);Console.WriteLine();}}public static void AddMatrix(int[,] array1, int [,] array2, int[,] array3){for(int row=0; row< array1.GetLength(0); row++){for(int column=0; column <array1.GetLength( 1 ); column++)array3[row, column] = array1 [row, column] + array2 [row, column];}for (int row = 0; row < array1.GetLength(0); row++){for (int column = 0; column < array1.GetLength(1); column++)Console.Write("{0}", array3[row, column]);}Console.WriteLine();}public static void SubtractMatrix(int[,] array1, int[,] array2, int[,] array3){for (int row = 0; row < array1.GetLength(0); row++){for (int column = 0; column < array1.GetLength(1); column++)array3[row, column] = array1[row, column] - array2[row, column];}for (int row = 0; row < array1.GetLength(0); row++){for (int column = 0; column < array1.GetLength(1); column++)Console.Write("{0}", array3[row, column]);}Console.WriteLine();}}{/CODE}推荐答案您好wkid87 请将您的代码与[code]标签放在一起以便于阅读。 我不认为Console没有Intt32方法或属性。 有一个网站,我遇到了搜索,特别是因为矩阵操作已经存在了很长时间时间 此网站提供使用的代码 欢呼Hi wkid87Please put your code withing [code] tags for readability.I dont think that Console does not have a Intt32 method or property.There is site which i came across doing a search, especially since matrix operations have been around for a very long time This site provides the code to usecheers 您好wkid87 请输入您的代码[代码]标签的可读性。 我这样做我认为控制台没有Intt32方法或属性。 有一个网站,我遇到了搜索,特别是因为矩阵操作已经存在很长时间了/> 此网站提供使用的代码 欢呼Hi wkid87Please put your code withing [code] tags for readability.I dont think that Console does not have a Intt32 method or property.There is site which i came across doing a search, especially since matrix operations have been around for a very long time This site provides the code to usecheers 感谢您的链接,但它没有任何帮助。没看到代码。 你知道如何从用户那里获取价值吗?Thanks for the link, but it did not help any. Didn''t see the code.Do you know how to get values from the user? 感谢您的链接,但它没有任何帮助。没看到代码。 你知道如何从用户那里获取价值吗?Thanks for the link, but it did not help any. Didn''t see the code.Do you know how to get values from the user? 代码将从网站上下载。 我认为它将作为一个库,其中定义了所有函数它,你需要的只是引用库并使用它中的方法。该算法应该在其中实现。 您的应用程序如何运行? Windows应用程序,基于控制台或基于Web? 欢呼well the code is to be donloaded from the site.I think it will be as a library, with all the functions defined in it, all you would need is to reference the library and use the methods in it. The algorithm should be implemented within that.How does your application run?Windows app, Console based, or web based?cheers 这篇关于C#init数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-27 17:13
查看更多