C楊輝三角用C語言怎麼寫?
最佳回答:
using System;
using System.Collections.Generic;
using System.Text;
namespace 斐波那契數列
{
class Program
{
static void Main(string[] args)
{
int a = 1, b = 1, i = 1, c,n;
n =Convert.ToInt32(Console.ReadLine());
Console.WriteLine("斐波那契排列");
Console.WriteLine("{0}\n{1}", a, b);
while (i < n - 1)
{
c = a + b;
Console.WriteLine("{0}", c);
a = b;
b = c;
i++;
}
Console.ReadKey();
}
}
}