1
2025-06-27 13:13:17
发布于:新疆
6阅读
0回复
0点赞
#include <iostream>
using namespace std;
void f(int n,int t){
if(n==0)return;
int r=n%2;
n=n/2;
f(n,t+1);
if(n!=0 &&r==1){
cout<<"+";
}
if(r==1){
if(t==0)cout<<"2(0)";
else if(t==1)cout<<"2";
else if(t==2)cout<<"2(2)";
else{
cout<<"2(";
f(t,0);
cout<<")";
}
}
}
int main() {
int n;
cin>>n;
f(n,0);
return 0;
}
这里空空如也
有帮助,赞一个