(no subject)
Jan. 22nd, 2004 10:16 pmAnybody know C-programming? Because I'm going crazy.
Basically it's supposed to take the input for a line of 1s and 0s then apply a rule to each successively generated line. It's meant to look at the cell directly above the active cell and the two cells touching that one. If they're all 1s or all 0s, the active cell is a zero, otherwise it's a 1.
For instance, if I input 0000100100
my output should be:
0000100100
0001111110
0011000011
0111100110
and so on but I'm just getting
1111111111
1111111111
1111111111
1111111111
If anybody can tell me where I'm going wrong with my sucking coding, I'll love you forever and ever. I've been working at this all day and I'm ready to kill the computer.
ETA: the code is here.
Basically it's supposed to take the input for a line of 1s and 0s then apply a rule to each successively generated line. It's meant to look at the cell directly above the active cell and the two cells touching that one. If they're all 1s or all 0s, the active cell is a zero, otherwise it's a 1.
For instance, if I input 0000100100
my output should be:
0000100100
0001111110
0011000011
0111100110
and so on but I'm just getting
1111111111
1111111111
1111111111
1111111111
If anybody can tell me where I'm going wrong with my sucking coding, I'll love you forever and ever. I've been working at this all day and I'm ready to kill the computer.
ETA: the code is here.
no subject
on 2004-01-22 02:44 pm (UTC)The bracket usage for a multiple alternative decision is as follows-
{
function_name;
if (condition)
A=B;
else if (condition)
A=C;
else if (condition)
A=D;
else
A=E;
return (void) /* if a return is needed from the function*/
}
no subject
on 2004-01-22 02:46 pm (UTC)no subject
on 2004-01-22 03:23 pm (UTC)I see you calling this function -
getch();
but I don't see the actual function defined anywhere.