【C#】项目1--斐波那契数列(人生中第一个C#程序)

来源:互联网 发布:电影票软件 编辑:程序博客网 时间:2024/05/01 23:52
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1   //1 1 2 3 5 {    class Program    {        static void Main(string[] args)        {            int a = 1, b = 1, c=0;            Console.WriteLine("Please input the number:");            string s = Console.ReadLine();            int number = int.Parse(s);            for (int i = 2; i < number; i++)            {                c = a + b;                a=b;                b = c;            }            Console.WriteLine("{0}",c);            Console.ReadLine();        }    }}


程序要求:

1.一列数的规则如下:1、1、2、3、5、8、13、21、34......。求第30位数是多少?

运行结果:

 

心得体会:

贺老师我又杀回来了!!

大二开始见不到你好桑心啊,要学C#和JAVA两门语言,而且他俩还挺像,总是给我整混了!!刚打开VS2008压根都不会用,还是喜欢我的codeblocks,是吧,还是C++可爱。

不过还是感谢老师上一年C++对我们的倾心教习,才让我们在大二伊始不至于更手忙脚乱。相信我老贺。他们都想你了

第一个程序很简单,曾经也用C++编过,现在的心情很复杂啊,我是个菜鸟,但是我会学习争取做个大菜鸟!

0 0
原创粉丝点击