本题主要考察数位分离
例如:210,输出
+(+!![]+!![]+[])+(+!![]+[])+(+[]+[])
可以看作3个部分
2:+(+!![]+!![]+[])
1:+(+!![]+[])
0:+(+[]+[])
每一位数都有“+(......+[])”
数为几中间就输出几个+!![],0则输出+[]
代码:
#include<iostream>
using namespace std;
int main(){
int n,w[20],cnt=0;
string s;
cin>>n;
if(n==0){
cout<<"+[]";
return 0;
}
while(n){
w[++cnt]=n%10;
n/=10;
}
for(int i=cnt;i>=1;i--){
s+="+(";
if(w[i]==0){
s+="+[]";
}else{
for(int j=1;j<=w[i];j++){
s+="+!![]";
}
}
s+="+[])";
}
cout<<s;
}