标签:
http://lx.lanqiao.org/problem.page?gpid=T235
1 #include<stdio.h> 2 void judge(int n) 3 { 4 int num = 0 , i = 0 , k , a[32]; 5 while(n) 6 { 7 if(n % 2) 8 a[num ++] = i; 9 i ++; 10 n /= 2; 11 } 12 for(i = num - 1;i >= 0;i --) 13 { 14 if(a[i] == 0) 15 printf("2(0)"); 16 else if(a[i] == 1) 17 printf("2"); 18 else if(a[i] == 2) 19 printf("2(2)"); 20 else 21 { 22 printf("2("); 23 judge(a[i]); 24 printf(")"); 25 } 26 if(i) 27 printf("+"); 28 } 29 } 30 int main() 31 { 32 int n; 33 while(~scanf("%d",&n)) 34 { 35 judge(n); 36 puts(""); 37 } 38 return 0; 39 }
标签:
原文地址:http://www.cnblogs.com/jeff-wgc/p/4450394.html