*   >> Læs Uddannelse artikler >> science >> programming

C # kode til at tilføje to Matrices

ved hjælp af System;

namespace AdditionOfTwoMatrices

{

///

///Resumé beskrivelse af Class1.

///

klasse Class1

{

public static int k = 0, l = 0, m = 0, n = 0;

///

///Det vigtigste indgang for anvendelsen.


///

[STAThread]

statisk void Main (string [] args)

{

//

//TODO: Tilføj kode til at starte programmet her

//

int [,] a = ny int [10,10]

int [,] b = new int [10,10]

int [,] c = ny int [10,10]

int [,] d = new int [10,10]

Class1 cs = ny Class1 ();

Console.Write ("Indtast rækkefølgen i Første Matric:")

k = int.Parse (Console.ReadLine ()),

Console.Write ("-");

< p> m = int.Parse (Console.ReadLine ()),

Console.WriteLine ();

Console.

Write ("Angiv rækkefølgen af ​​Second Matric:");

l = int.Parse (Console.ReadLine ()),

Console.Write ("-")

n = int.Parse (Console.ReadLine ()) ;

if (l == k && m == n)

{

Console.WriteLine ("\\ nIndtast Værdien af ​​First Matrice:");

cs.matrice (a)

Console.WriteLine ("Indtast Værdien af ​​Second Matrice:")

cs.matrice (b)

Console.WriteLine ("Matricer indtastet are:");

cs.arrange(a);

Console.WriteLine();

cs.arrange(b);

Console.WriteLine("Addition af to matricer er: ");

cs.

addition (a, b);

}

andet

{

Console.WriteLine ("Addition er ikke muligt")

}

Console.ReadLine ();

}

public void matrice (int [ ,,,0],,] c)

{

for (int i = 0; i

​​{

for (int j = 0; j

{

c [i, j] = int.Parse (Console.ReadLine ()),

}

}

}

public void arrangere (int [,] c)

{

for (int i = 0; i

​​{

for (int j=0;j

{

Console.Write(c[i,j]+"\\t");

}

Console.

WriteLine();

}

}

public void tilføjelse (int [,] c, int [,] d)

{

for (int i = 0; i

​​{

for (int j=0;j

{

Console.Write((c[i,j]+d[i,j])+"\\t");

}

Console.WriteLine();

}

}

}

}


Copyright © 2008 - 2016 Læs Uddannelse artikler,https://uddannelse.nmjjxx.com All rights reserved.