Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Shuttle(double[,] arr)
- {
- List<double> P = new List<double>();
- List<double> A = new List<double>();
- List<double> Q = new List<double>();
- P.Add(arr[0, 0]);
- A.Add(-arr[0, 1] / P[0]);
- Q.Add(arr[0,arr.GetLength(0)] / P[0]);
- /////////////////////////////////////////////
- int j = 0;//под главной
- for(int i = 1; i < arr.GetLength(0); i++)
- {
- int m = i + 1;//над главной
- P.Add(arr[i, i] + arr[i, j] * A[j]);
- A.Add(-arr[i, m] / P[i]);
- Q.Add((arr[i, arr.GetLength(0)] - arr[i, j] * Q[j]) / P[i]);
- j++;
- }
- A.Remove(A[A.Count-1]);
- /////////////////////////////////////////////
- List<double> X = new List<double>(arr.GetLength(1)-1);
- X.Add(Q[Q.Count - 1]);
- Console.WriteLine("X[" + Q.Count + "]=" + X[0]);
- int jj = 0;
- for(int i = A.Count; i > 0; i--)
- {
- X.Add(A[i-1] * X[jj] + Q[i-1]);
- jj++;
- Console.WriteLine("X[" + i + "]=" + X[jj]);
- }
- }
- public static void Main()
- {
- double[,] array = new double[,] { { 2, -1, 0, 0, 0, -25 }, { -3, 8, -1, 0, 0, 72 },
- { 0, -5, 12, 2, 0, -69 },{ 0, 0, -6, 18, -4, -156 },{0,0,0,-5,10,20 } };
- for(int i = 0; i < array.GetLength(0); i++)
- {
- for(int j = 0; j < array.GetLength(1); j++)
- {
- Console.Write(array[i, j] + "");
- Console.Write("|");
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Shuttle(array);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment