Code: Select all
void calculate(unsigned int number, int cow, char bleh, double three, long double eight)
{
printf("%u\n",number);
calculate(number+1, cow+5, three+2, eight, bleh-1);
}
Moderator: General Mods
Code: Select all
void calculate(unsigned int number, int cow, char bleh, double three, long double eight)
{
printf("%u\n",number);
calculate(number+1, cow+5, three+2, eight, bleh-1);
}
Code: Select all
void calculate(int x, int y, int z) {
printf("%2d %2d %2d\n", x, y, z);
//x, y, z -> y, z, x = rotate variables left by 1 (3-step loop)
//x = y + 2
//y = z
//z = x - 1
calculate(y + 2, z, x - 1);
}
Code: Select all
0 0 0= 0
2 0 -1= 1
2 -1 1= 2
1 1 1= 3
3 1 0= 4
3 0 2= 5
2 2 2= 6
4 2 1= 7
4 1 3= 8
3 3 3= 9
5 3 2=10
5 2 4=11
4 4 4=12
6 4 3=13
6 3 5=14
Seriously, why are you making up your own code instead of telling me what mine does? You removed some key variables, you're printing totally different things than mine is... I'll give you one thing, you DID pull an interesting pattern out of some variables there.byuu wrote:Blah Blah Blah Code Blah Blah
Oh shoot... gotta fix that... *Goes back and edits the original post*Nach wrote:Cute, I think you meant to have that first param be unsigned and change it to %u though.
No.odditude wrote:Is it safe to assume that 'char' ranges from -128 to 127, unsigned int from 0 to 65535, and int from -32768 to 32767?
1) Because I don't know what your code does.Seriously, why are you making up your own code instead of telling me what mine does? You removed some key variables, you're printing totally different things than mine is... I'll give you one thing, you DID pull an interesting pattern out of some variables there.
1) Looking at a fridge won't help you figure out how an internal combustion engine works.byuu wrote: 1) Because I don't know what your code does.
2) Because you don't ever actually use either cow or number for anything other than a printf statement.
3) Because that's the way I analyze problems.
4) I have to guess what inputs to give the first calculate call, since you never specified start values, hence why we have different outputs. The last three vars should be the same for both of ours. I only changed their names.
But if you're going to get upset over it, I'll move on. I don't know what it does. It looks like gibberish to me with no context. Maybe someone else can solve it, then.
No, it compiles fine, no warnings even.funkyass wrote:assuming the function in question would actually compile...
stuffing a char into a long double might make the compiler question the sanity of the programmer. Putting a double into a char would make the compiler phone the police.
correct. It's to test how much stack space there is. You win the prize, i WON'T come over to your house and kill you. Thank you for playing.Nach wrote: Okay, since people are getting upset over this, I'll give away the answer, and this should have been obvious (at least it was to me when I first saw it).
This function is recursive, and seems to run until it crashes, each time printing out the value of number which increments by one per itteration. The other parameters don't seem to do anything but take up stack space.
So assuming that the first call to the function is with number being equal to 0/1, it counts how many times a recursive function can call itself with 2 ints, a char, a double, and a long double.
You should be safe to have recursion go up to 100,000 times or so on modern PCs.
Easy enough to do that without the need for all the variables. Then you can extrapolate by testing sizeof() on each type you want. I did this when choosing recommended defaults for thread heap sizes.correct. It's to test how much stack space there is.
Code: Select all
void heapsize() {
static int size = 0;
size += sizeof( void (*)() );
printf("heap ~= %d bytes\n", size);
heapsize();
}
Analogies aside, I think I typically do quite well reverse engineering stuff. Of course, I can't even compare to Nach, blargg or anomie. Which is actually kind of nice, I like having others to seek advice from and aspire to.1) Looking at a fridge won't help you figure out how an internal combustion engine works.
Bah, seconded. I was hoping it would hold a special mathematic property or something.Lame riddle. The answer is a crashing program...
byuu wrote:I was hoping it would hold a special mathematic property or something.
Code: Select all
typedef enum { knf, sw1, sw2, ax1, ax2, ham, spr, stf, fll, bow, glv, NA} wname;
struct
{
uint8_t inc[7];
bool used;
} weap[11];
static void next_step(uint8_t table[11], const wname last)
{
wname lnz = last;
uint8_t tmp;
while (!table[lnz] || !weap[lnz].used) { lnz--; }
if (lnz == last)
{
tmp = table[lnz];
table[lnz] = 0;
do { lnz--; } while (!table[lnz] || !weap[lnz].used);
}
else { tmp = 0; }
table[lnz]--;
do { lnz++; } while (!weap[lnz].used);
table[lnz] = tmp+1;
}
Code: Select all
<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)