zacaj said:
What would be faster?
What would be better(less resource use, etc)?
Depends a lot on the compiler as well as other stuff in your code. Best to profile everything always.
zacaj said:
A switch statement that chooses what function to run based on a variable, or an array or pointers to the functions?
Based on my testing with my 8051 emulator, which basically just takes an opcode and then figures out what to do with it, there's little difference. The switch basically compiles into a jump table anyway in most cases, and whichever you choose, you get the worst case scenario for branch prediction. Switch structure may be more "safe" in the way that there's less things that can go wrong, but your mileage may vary.
zacaj said:
Dividing, or making a 2D array of answers to division?
This depends a lot on the compiler. The table is probably the worst choice unless it's very small and used very often so that it fits into the cache.
Instead, if this is integer division, consider doing it with shifts (any integer division can be split into shifts, additions and substractions), and if non-integers, multiply by the reciprocal of the divisor (i.e. instead of v = x / y, do z = 1/y, v = x * z). There are plenty of math tricks around - search the web.
zacaj said:
An if with multiple questions ( if(g>i&&j<h) ) or two if's ( if(g>i) if(j<h) )?
The C compiler has an "early out" mechanism, so if you have, for instance if (foo() && bar()) and foo returns false, bar() is never called. But to answer the question, both are probably just as fast. Modern compilers should turn those into an identical data-flow graph, which is then used to actually generate code.
zacaj said:
Drawing a grid, or drawing a picture of one?
Depends a lot on what this grid is =). If the algorithm to figure out the grid is simple enough, it'll stay inside the CPU cache - reading from the picture will probably trash the data cache.