*   >> Lezen Onderwijs artikelen >> science >> programming

C # code voor het toevoegen van twee Matrices

using System;

namespace AdditionOfTwoMatrices

{

///

///Summary beschrijving van Class1.

///

class Class1

{

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

///

///Het belangrijkste punt voor de toepassing.

///

[STAThread]

statische void Main (string [] args)

{

//

//TODO: code toevoegen om te beginnen met de toepassing hier

//

int [,] a = new int [10,10];

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

int [,] c = new int [10,10];

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

Class1 cs = new Class1 ();

Console.

Write ("Geef de volgorde van de Eerste Matric: ');

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

Console.Write (" - ");

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

Console.WriteLine ();

Console.Write ("Geef de volgorde van de Tweede Matric: ');

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

Console.Write ("-");

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

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

{

Console.WriteLine ("\\ nGeef De waarde van eerste Matrice: ');

cs.matrice (a);

Console.WriteLine ("Voer de waarde van Second Matrice: ');

cs.matrice (b);

Console.

WriteLine ("Matrices ingevoerd are:");

cs.arrange(a);

Console.WriteLine();

cs.arrange(b);

Console.WriteLine("Addition van twee matrices is: ');

cs.addition (a, b);

}

anders

{

Console.WriteLine ("Addition is niet mogelijk");

}

Console.ReadLine ();

}

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

{

for (int i = 0; i

​​{

voor (int j = 0; j

{

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

}

}

}

public void regelen (int [,] c)

{

for (int i = 0; i

​​{

voor (int j=0;j

{

Console.

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

}

Console.WriteLine();

}

}

public leegte toevoeging (int [,] c, int [,] d)

{

for (int i = 0; i

​​{

voor (int j=0;j

{

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

}

Console.WriteLine();

}

}

}

}


Copyright © 2008 - 2016 Lezen Onderwijs artikelen,https://onderwijs.nmjjxx.com All rights reserved.