Professional Documents
Culture Documents
using System;
using System.Collections.Generic;
using System.Text;
namespace Proyecto
{
class Program
{
static void Main(string[] args)
{
Sample1();
}
static void Sample1()
{
x+y+z=6 |1116|
x+z=4 |1014|
x+y=3 | 1 1 0 3 | */
double[,] a = new double[3, 4];
Console.WriteLine("\n * Ingrese los elementos de la Matriz * \n");
for (int i = 0; i <= 2; i++)
{
for (int j = 0; j <= 3; j++)
{
Console.Write("\tIngrese el elemento [{0},{1}] : ", i, j);
a[i, j] = double.Parse(Console.ReadLine());
}
} Console.Write("\n");
if (LinearEquationsSolver.GaussianElimination(a, r))
ShowSolution(r);
else
Console.WriteLine(Title + '\n');
for (int i = 0; i <= a.GetUpperBound(0); i++)
{
Console.Write('|');
Console.Write(ToStringSign(a[i, j]));
Console.Write(" | \n");
Console.WriteLine('\n');
Console.WriteLine(ToStringSign(r[i]));
Console.WriteLine("\n");
if (v < 0) return ' ' + v.ToString(); else return " " + v.ToString();
#endregion
}
}
LA CLASE
using System;
using System.Collections.Generic;
using System.Text;
namespace Proyecto
{
class LinearEquationsSolver
{
public static bool GaussianElimination(double[,] a, double[] r)
{
double t, s;
int i, l, j, k, m, n;
try
{
n = r.Length - 1;
m = n + 1;
j = l;
if (!(j == l))
{
t = a[l, i];
a[j, i] = t;
j = n - i - 1;
s = 0;
k = j + l + 1;
s += a[j, k] * r[k];
return true;
catch
{
return false;
}
}
}