从1加到任意数

   int c = 0;
            Console.WriteLine("请输入一个数");
            int n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
            {
                c = c + i;
            }
            Console.WriteLine(c);
            Console.ReadLine();

posted @ 2009-11-17 15:23  kin2321  阅读(251)  评论(0编辑  收藏  举报