9、用伪代码实现下面两道题,写出关键部分即可(每小题15分) a)给出正整数(int 范围内)以逆序形式输出(如给出n=12345,输出54321)。 b) 一列数的规则如下:1、1、2、3、5、8、13、21、34.....,求第位数,要求用递归实现用java代码实现
时间: 2023-12-28 16:59:30 浏览: 61
a) 伪代码:
输入n
while n>0 do
输出n%10
n=n/10
end while
b) 伪代码:
输入n
if n=1 or n=2 then
输出1
else
输出 Fibonacci(n-1) + Fibonacci(n-2)
end if
其中Fibonacci为递归函数,实现如下:
Fibonacci(n){
if n=1 or n=2 then
return 1
else
return Fibonacci(n-1) + Fibonacci(n-2)
end if
}
阅读全文
相关推荐
![cpp](https://img-home.csdnimg.cn/images/20250102104920.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)