Advertisement
Jater

finite difference method

May 1st, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication3
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             double[] dy = { 12.4, 45.6, 10, 45.1, 76.1 };
  13.             int l = dy.Length;
  14.             double[,] dyy = new double[l,l];
  15.  
  16.             for (int i = 0; i < l; i++)
  17.                 dyy[0, i] = dy[i];
  18.  
  19.             for (int i = 1; i < l; i++)
  20.             {
  21.                 for (int j = 1; j < l - i + 1; j++)
  22.                     dyy[i, j - 1] = dyy[i - 1, j] - dyy[i - 1, j - 1];
  23.             }
  24.  
  25.             for (int i = 0; i < l; i++)
  26.             {
  27.                 for (int j = 0; j < l-i; j++)
  28.                 {
  29.                     Console.Write(dyy[i, j] + "; ");
  30.                 }
  31.                 Console.Write("\n");
  32.             }
  33.             Console.ReadLine();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement