C#递归
2021-03-04 00:28
标签:ons nbsp using 个数 pre write space 算法 col 有一组数,1,1,2,3,5,8,……,用递归算法算出第三十个数 C#递归 标签:ons nbsp using 个数 pre write space 算法 col 原文地址:https://www.cnblogs.com/kyuusan/p/12951280.html 1 using System;
2
3 namespace ConsoleApp1
4 {
5 class Program
6 {
7 static void Main(string[] args)
8 {
9 int sLeft = 1, sRight = 1, sum = 0, count = 28; //sLeft 为每次递归左边的值,sRight为每次递归右边的值,sum为寄存总值的变量,count为循环次数
10 while (count >= 1)
11 {
12 sum = sLeft + sRight;
13 sLeft = sRight;
14 sRight = sum;
15 count--;
16 Console.WriteLine(sum);
17 }
18 }
19 }
20 }
上一篇:如何手动安装yapi