labResult.Text += "标签打印显示fibonacci数列的前15项: 1,1,2,3,5,8,13,……:\n" ; |
int [] intArray = new int [15]; |
intArray[0] = 1; |
intArray[1] = 1; |
for ( int i = 2; i < intArray.Length; i++ ) |
{ |
intArray[i] = intArray[i - 1] + intArray[i - 2]; //第i位上的数等于前两位数之和 |
} |
//打印显示此数组 |
foreach ( int i in intArray ) |
{ |
labResult.Text += i + " " ; |
} |
#endregion |
by: 发表于:2018-01-15 09:56:23 顶(0) | 踩(0) 回复
??
回复评论