using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12{
class Program
{
public const int N = 3;
// simple iteration method procedure
static public void ProstIterMetode(double[,]a, double[] d)
{
int i,j;
double[] x0 = new double [N];
double delta;
double[] E = new double [N];
double[] x = new double [N];
x0=d;
do {
for (i=0; i< N; i++)
{
x[i]=0;
for(j=0; j< N; j++)
{
x[i]=x[i]+a[i,j]*x0[j];
}
x[i]=x[i]+d[i];
E[i]=Math.Abs(x[i]-x0[i]);
}
delta=E[0];
for (i=1; i< N; i++)
{
if (delta<E[i]) delta=E[i];
};
x0=x;
} while(delta<=0.000001);
for (i = 0; i < N; i++)
Console.WriteLine(x[i]);
}
static void Main(string[] args)
{
double[,] a = new double[N, N];
double[] b = new double[N];
double[] x = new double[N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
a[i, j] = i+1; // Convert.ToDouble(Console.ReadLine());
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
Console.Write(a[i, j] + " ");
Console.WriteLine();
}
Console.WriteLine("Input b");
for (int i = 0; i < N; i++)
b[i] = i + 1;//Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Input x");
for (int i = 0; i < N; i++)
x[i] = i + 1; //Convert.ToDouble(Console.ReadLine());
ProstIterMetode(a, b);
}
}
}
Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. ayna yazı ve ters yazı yazma
ReplyDelete