#define N 10000
int e[N], h[N], nt[N], idx;
vector<int>d;
int temmp[N];
void add(int a,int b)
{
e[idx] = b, nt[idx] = h[a], h[a] = idx++;
}
void FJ(int x)
{
if (!temmp[x])
{
temmp[x] = 1;
d.clear();
int temp = x;
int t = 0;
while (x)
{
if ((x & 1) == 1) //10001000
{
//cout << t << ' ';
d.push_back(t);
}
t++;
x /= 2;
}
for (auto i:d)
{
add(temp, i);
if(i==7)
cout << i << ' ';
if (i > 2)
FJ(i);
}
}
}
void PRINT(int n)
{
for (int i = h[n]; i != -1; i = nt[i])
{
int j = e[i];
if (j <= 2)
{
if (j !=1)
cout << 2 << '(' << j << ')';
else if(j==1)cout <<2;
if (nt[i] != -1)cout << '+';
}
else
{
cout << 2 << '(';
PRINT(j);
cout << ')';
if(nt[i]!=-1)
cout<< '+';
}
}
}
大佬们请看我的FJ函数还有add函数,我遇到的问题是,为什么当x为136是 7不可以被正确添加到136的后续链表里,这是为什么啊?不理解!!!