• Segitiga Pascal dengan C#

    by  • September 4, 2011 • Ilmiah • 0 Comments

    iseng mengisi blog yang rada keteteran gara-gara kerjaan, sekarang saya iseng ngepost cara perhitungan segitiga pascal pake C# ah :D

    static void Main(string[] args)
            {
                int row = 5;
               for (int i = 0; i < row; i++)
               {
                   int c = 1;
    
                    // Prints the blank spaces
                    for (int j = 1; j <= row - i; j++)
                    {
                        Console.Write(" ");
                    }
    
                    // Prints the value of the number
                    for (int k = 0; k <= i; k++)
                    {
                        Console.Write(c + " ");
                        c = c * (i - k) / (k + 1);
                        Console.Write("({0})", c);
                    }
                    Console.WriteLine();
                }
            }

    About

    C# & Java based code crafter | Fan of Joomla&Wordpress | #android LG Optimus One+2X enthusiast | PC-Gamer | J-Dorama Maniac | Googlist