您当前的位置: 首页 >  c#

苍狼王unity学院

暂无认证

  • 1浏览

    0关注

    305博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

补点C#基础_08_函数的递归调用

苍狼王unity学院 发布时间:2019-07-24 11:43:01 ,浏览量:1

1、 static int F(int n) { if (string.Equals(n,0)) { return 2; } if (string.Equals(n, 1))//这两个是函数终止递归的条件。 { return 3; } return F(n - 1) + F(n-2);//函数调用自身,叫做递归调用。, } static void Main(string[] args) { int res = F(20); Console.WriteLine(res); int res2 = F(2); Console.WriteLine(res2); Console.ReadKey(); }

2、 在这里插入图片描述

关注
打赏
1665389160
查看更多评论
立即登录/注册

微信扫码登录

0.0770s