Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How should I start coding this?
Posted 23-Nov-12 12:45pm
Edited 3-Dec-12 8:36am
v2
Comments
Sergey Alexandrovich Kryukov at 23-Nov-12 18:18pm
   
Not a valid question. What's "how"?
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I would start with the first row (and the mathematical definition [^]).
You may use the recurrence relation (shown in the linked page) to compute their values (in a simple, rough approach, you might use a 10 x 10 array to store the numbers as computation proceedes).
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

This is a little simpler and more flexible implementation:
 
public static void EeulerBernoulli(int limit)
{
    var E = new List<int[]>();
 
    for (int n = 0; n < limit; n++)
    {
        E.Add(new int[n + 1]);
        for (int k = 0; k <= n; k++)
        {
            E[n][k] = (k != 0) ? (E[n][k - 1] + E[n - 1][n - k]) : 
                (n == 0 ? 1 : 0);
        }
    }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Just use an query like this
 
select TOP 10 from tablename
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

static void CreatEeulerBernoulli()
{
   euler_Bernoulli[0, 0] = 1;
   for (int i = 1; i < 10; i++)
   {
      if (i % 2 == 0)
         evenArray(i);
      else
         oddArray(i);
   }
   WriteToScreen(euler_Bernoulli);
}
 
static void oddArray(int currentIndex)
{
   for (int i = 0; i < currentIndex; i++)
   {
      int currentSum = 0;
      for (int j = 0; j < currentIndex - i; j++)
         currentSum = euler_Bernoulli[currentIndex - 1, j] + currentSum;
         
      if (currentIndex >= i)
         euler_Bernoulli[currentIndex, currentIndex - i] = currentSum;
   }
}
 
static void evenArray(int currentIndex)
{
   for (int i = 0; i < currentIndex; i++)
   {
      int currentSum = 0;
      for (int j = i; j < 10; j++)
         currentSum = euler_Bernoulli[currentIndex - 1, j] + currentSum;
      
      if (currentIndex >= i)
         euler_Bernoulli[currentIndex,  i] = currentSum;
   }
}
 
static void WriteToScreen(int[,] result)
{
   for (int i = 0; i < 10; i++)
   {
      Console.WriteLine("array index of " + i.ToString());
      for(int k=0; k<10; k++)
         Console.Write((result[i,k].ToString())+",");
   }
}
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100