基础题。
#include <iostream>
using namespace std;
int two[1000];
int main()
{
int d;
cin >> d;
while (d--)
{
int n;
cin >> n;
int index = 0;
while (n != 0)
{
two[index++] = n % 2;
n /= 2;
}
int i;
for (i = 0; i < index - 1; i++)
{
if (two[i] == 1)
cout << i << " ";
}
cout << index - 1 << endl;
}
return 0;
}
继续加油。