3 ms·
Aside: this test code would have been a bit easier to debug if it had used decimal bases. That is, replace int a[] = {10,20,30}; int r = 1 * a[i++] + 2 * a
by thisisnotatest 13y ago
Aside: this test code would have been a bit easier to debug if it had used decimal bases. That is, replace
int a[] = {10,20,30};
int r = 1 * a[i++] + 2 * a[i++] + 3 * a[i++];
with
int a[] = {1,2,3};
int r = 1 * a[i++] + 10 * a[i++] + 100 * a[i++];
Then if your program outputs r = 111, it's obvious that it's doing
a[0] + 10*a[0] + 100*a[0]
and if it outputs 321, it's obvious that it's doing
a[0] + 10*a[1] + 100*a[2]
No disassembly required.
- Perseids 13y agoAlternatively just think a moment longer and realize that the lower limit of each value (10) already produces 60 and thus each must must be 10.