这是一项家庭作业。我想我已经设法弄明白了,但由于某些原因我的解决方案不起作用。
所以有一个包含6个节点的linked_list,我的答案是一个由空格分隔的6个整数的字符串。数字的范围只能是1到6.根据我的理解,这一切都归结为按节点值的降序对列表进行排序,答案是节点的顺序。
就我而言,恰好是:
node 6: 574
node 5: 385
node 4: 188
node 3: 675
node 2: 785
node 1: 952
降低顺序:1-> 2-> 3-> 6-> 5-> 4
虽然有时候,我会得到一组不同的节点值:
n1 -72
n2 17
n3 -93
n4 -68
n5 -127
n6 62
降低顺序:6-> 2-> 4-> 1-> 3-> 5
但出于某种原因,这6个数字都不起作用。我也按升序尝试了。我只收到这两组节点值中的一个。以下是我的代码的汇编转储:
Dump of assembler code for function phase_6:
0x00000000004010b6 <+0>: push %r14
0x00000000004010b8 <+2>: push %r13
0x00000000004010ba <+4>: push %r12
0x00000000004010bc <+6>: push %rbp
0x00000000004010bd <+7>: push %rbx
0x00000000004010be <+8>: sub $0x50,%rsp
0x00000000004010c2 <+12>: lea 0x30(%rsp),%rsi
0x00000000004010c7 <+17>: callq 0x401645 <read_six_numbers>
0x00000000004010cc <+22>: lea 0x30(%rsp),%r12
0x00000000004010d1 <+27>: mov %r12,%r13
0x00000000004010d4 <+30>: mov $0x0,%r14d
0x00000000004010da <+36>: mov %r13,%rbp
0x00000000004010dd <+39>: mov 0x0(%r13),%eax
0x00000000004010e1 <+43>: sub $0x1,%eax
0x00000000004010e4 <+46>: cmp $0x5,%eax
0x00000000004010e7 <+49>: jbe 0x4010ee <phase_6+56>
0x00000000004010e9 <+51>: callq 0x4014e4 <explode_bomb>
0x00000000004010ee <+56>: add $0x1,%r14d
0x00000000004010f2 <+60>: cmp $0x6,%r14d
0x00000000004010f6 <+64>: je 0x40111a <phase_6+100>
0x00000000004010f8 <+66>: mov %r14d,%ebx
0x00000000004010fb <+69>: movslq %ebx,%rax
0x00000000004010fe <+72>: mov 0x30(%rsp,%rax,4),%edx
0x0000000000401102 <+76>: cmp %edx,0x0(%rbp)
0x0000000000401105 <+79>: jne 0x40110c <phase_6+86>
0x0000000000401107 <+81>: callq 0x4014e4 <explode_bomb>
0x000000000040110c <+86>: add $0x1,%ebx
0x000000000040110f <+89>: cmp $0x5,%ebx
0x0000000000401112 <+92>: jle 0x4010fb <phase_6+69>
0x0000000000401114 <+94>: add $0x4,%r13
0x0000000000401118 <+98>: jmp 0x4010da <phase_6+36>
0x000000000040111a <+100>: lea 0x48(%rsp),%rcx
0x000000000040111f <+105>: mov $0x7,%edx
0x0000000000401124 <+110>: mov %edx,%eax
0x0000000000401126 <+112>: sub (%r12),%eax
0x000000000040112a <+116>: mov %eax,(%r12)
0x000000000040112e <+120>: add $0x4,%r12
0x0000000000401132 <+124>: cmp %rcx,%r12
0x0000000000401135 <+127>: jne 0x401124 <phase_6+110>
0x0000000000401137 <+129>: mov $0x0,%esi
0x000000000040113c <+134>: jmp 0x401157 <phase_6+161>
0x000000000040113e <+136>: mov 0x8(%rdx),%rdx
0x0000000000401142 <+140>: add $0x1,%eax
0x0000000000401145 <+143>: cmp %ecx,%eax
0x0000000000401147 <+145>: jne 0x40113e <phase_6+136>
0x0000000000401149 <+147>: mov %rdx,(%rsp,%rsi,2)
0x000000000040114d <+151>: add $0x4,%rsi
0x0000000000401151 <+155>: cmp $0x18,%rsi
0x0000000000401155 <+159>: je 0x40116c <phase_6+182>
0x0000000000401157 <+161>: mov 0x30(%rsp,%rsi,1),%ecx
0x000000000040115b <+165>: mov $0x1,%eax
0x0000000000401160 <+170>: mov $0x6033d0,%edx
0x0000000000401165 <+175>: cmp $0x1,%ecx
0x0000000000401168 <+178>: jg 0x40113e <phase_6+136>
0x000000000040116a <+180>: jmp 0x401149 <phase_6+147>
0x000000000040116c <+182>: mov (%rsp),%rbx
0x0000000000401170 <+186>: mov 0x8(%rsp),%rax
0x0000000000401175 <+191>: mov %rax,0x8(%rbx)
---Type <return> to continue, or q <return> to quit---
0x0000000000401179 <+195>: mov 0x10(%rsp),%rdx
0x000000000040117e <+200>: mov %rdx,0x8(%rax)
0x0000000000401182 <+204>: mov 0x18(%rsp),%rax
0x0000000000401187 <+209>: mov %rax,0x8(%rdx)
0x000000000040118b <+213>: mov 0x20(%rsp),%rdx
0x0000000000401190 <+218>: mov %rdx,0x8(%rax)
0x0000000000401194 <+222>: mov 0x28(%rsp),%rax
0x0000000000401199 <+227>: mov %rax,0x8(%rdx)
0x000000000040119d <+231>: movq $0x0,0x8(%rax)
0x00000000004011a5 <+239>: mov $0x5,%ebp
0x00000000004011aa <+244>: mov 0x8(%rbx),%rax
0x00000000004011ae <+248>: mov (%rax),%edx
=> 0x00000000004011b0 <+250>: cmp %edx,(%rbx)
0x00000000004011b2 <+252>: jge 0x4011b9 <phase_6+259>
0x00000000004011b4 <+254>: callq 0x4014e4 <explode_bomb>
0x00000000004011b9 <+259>: mov 0x8(%rbx),%rbx
0x00000000004011bd <+263>: sub $0x1,%ebp
0x00000000004011c0 <+266>: jne 0x4011aa <phase_6+244>
0x00000000004011c2 <+268>: add $0x50,%rsp
0x00000000004011c6 <+272>: pop %rbx
0x00000000004011c7 <+273>: pop %rbp
0x00000000004011c8 <+274>: pop %r12
0x00000000004011ca <+276>: pop %r13
0x00000000004011cc <+278>: pop %r14
0x00000000004011ce <+280>: retq
End of assembler dump.