题目如下:
代码如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#include <iostream> #include <cmath> using namespace std; void out1(int a) { int t1,t2; if(a==1) { cout<<"2(0)"; return; } t1=int(log(a)/log(2)); t2=a-pow(2,t1); cout<<"2"; if(t1!=1) { cout<<"("; out1(t1); cout<<")"; } if(t2!=0) { cout<<"+"; out1(t2); } } main() { int a; cin>>a; out1(a); }
运行结果如下:
还有一个:
转载于:https://www.cnblogs.com/wanjinliu/p/11385452.html
最后
以上就是忐忑书包最近收集整理的关于用2的幂次方表示任意整数--递归的全部内容,更多相关用2内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复