首页 > 编程语言 > 详细

C# 递归算法与冒泡

时间:2016-04-12 19:32:39      阅读:158      评论:0      收藏:0      [点我收藏+]

C# 递归算法求 1,1,2,3,5,8,13···
static void Main(string[] args)
{

int[] cSum = new int[10];
for (int i = 0; i < cSum.Length; i++)
{
cSum[i] = Pro_WriteNum(i);
Console.WriteLine(cSum[i]);
}
Console.ReadLine();
}

private static int Pro_WriteNum(int a)
{
int result = 0;
if (a == 0 || a == 1)
{
result = 1;
}
else
{
result = Pro_WriteNum(a - 1) + Pro_WriteNum(a - 2);
}
return result;

}
-------------------------------------------------------------
int temp;
int[] arrSort = new int[] { 10, 8, 3, 5, 6, 7, 9 };
for (int i = 0; i < arrSort.Length; i++)
{
for (int j = i + 1; j < arrSort.Length; j++)
{
if (arrSort[j] < arrSort[i])
{
temp = arrSort[j];
arrSort[j] = arrSort[i];
arrSort[i] = temp;
}
}
}

C# 递归算法与冒泡

原文:http://www.cnblogs.com/chengjun/p/5383731.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!