ZOJ 1383题解,乘着媛姐讲课做了一道水题,不做不知道,一做还真是水题!
1 #include<stdio.h>
2
3 int main()
4 {
5 int i, ncases;
6 int n;
7
8 while(scanf("%d", &ncases) != EOF)
9 {
10 while(ncases--)
11 {
12 scanf("%d", &n);
13 i = 0;
14 while( n != 0)
15 {
16 if(n%2 == 1)
17 {
18 if(n/2 != 0)
19 printf("%d ",i);
20 else
21 printf("%d",i);
22 }
23 n /= 2;
24 i++;
25 }
26 printf("\n");
27 }
28 }
29 return 0;
30 }