C# 冒泡排序与递归
作者:互联网
冒泡:
1 //将 1, 5, 6, 8, 4, 3, 9, 2, 7 按照从小到大排序 2 3 int [] a={ 1, 5, 6, 8, 4, 3, 9, 2, 7 } 4 5 int temp; 6 for (i=0 , i< a.lenght ,i++) 7 { 8 9 for(j=i+1,j<a.lenght,j++) 10 { 11 if (a[i]>a[j]) 12 { 13 temp=a[i]; 14 a[i]=a[j]; 15 a[j]=temp; 16 17 } 18 } 19 }
递归:
1 //1,1,2,3,5,8,13 第10位数是多少 2 3 foot(10) 4 5 public state int foot(int count) 6 { 7 if (count <=0) 8 return 0; 9 else if(count >0 && count <=2) 10 return 1; 11 else 12 return foot(count -1)+ foot(count -2) 13 }
标签:count,10,13,递归,temp,C#,冒泡排序,int,foot 来源: https://www.cnblogs.com/hsf-bk/p/14593979.html