
这个题难度不高,难点可能是把算式打印出来
# include <iostream>
using namespace std;
int main(){
int a,b;
cin >> a;
while (a != 1){
if (a % 2 != 0){
cout << a <<"*3+1=";
a = a * 3 + 1;
}else{
cout << a <<"/2=";
a = a / 2;
}
cout <<a<<endl;
}
cout << "End"<<endl;
return 0;
}
本文介绍了一个使用C++编写的程序,通过递归实现斐波那契数列,并在每次迭代中打印出计算过程的算式。程序在用户输入非1的整数时,逐步执行递归逻辑直到1,最后输出End。
1134

被折叠的 条评论
为什么被折叠?



