2008-04-10 15:55
using System; using System.Collections.Generic; using System.Text;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("请输入最大数n"); int n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(sum(n)); } private static int sum(int n) { int nsum; if (n == 1) nsum = 1; else nsum = n * n + sum(n - 1); return nsum; } } }
|
本文转自悬魂博客园博客,原文链接:http://www.cnblogs.com/xuanhun/archive/2010/02/03/1662393.html,如需转载请自行联系原作者