Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Zorb Burger

Pages: [1]
1
Off-Topic / Re: Divide Function and Multiply Function.
« on: 2009-05-04, 09:09:01 PM »
Hey, bluemonkmn.

The reason why I'm asking these questions is simply for fun.  I was asked the questions on an entrance exam for EA Games.  I've already gone through programming "boot camp" so I'm not trying to get answers for a test or anything.

Also, a recursive function iis allowed, just not "for-loops", "while-loops" and "do-while loops".  That's a very nice way of figuring out that question.

And about my way of doing the divide question, I'm going to need look over that... I thought for sure it worked, but nobody's perfect.

~Zorb Burger

2
Off-Topic / Re: Divide Function and Multiply Function.
« on: 2009-05-04, 05:23:18 PM »
DAAYUUMM!!

*sigh*

I knew I messed something up in there... I meant that you could not use the multiplication and division operators...for both of them.

Also, about the mult7 function, it can be reduced further:

int mult7(int num)
{
     return (num<<3) - num;
}

and here's what I got for the divide:

int divide(int num, int den)
{
   int orig = den;
   int shifts = 0;
   while( num > den)
   {
      den <<= 1;
      ++shifts;
   }
   den >>= 1; --shifts;
   int count = 0;
   while(den > orig && num > den)
   {
      count += 1 << shifts;
      num -= dem;
      dem >>= 1;
   }
   if( num > dem )
      ++count;
   return count;
}

Thanks for participating in the questions, durnurd.  I figured you'd try it out.
Well...the next question I have will deal with strings.  :)

// Basically this function calculates the length of the null terminated string.
// You cannot use any functions that you didn't make yourself and you can't
// use loops.
int strlen(char *sz)
{
}

3
Off-Topic / Divide Function and Multiply Function.
« on: 2009-05-04, 12:15:26 PM »
Greetings everyone.

I have two questions for anyone willing to try them (they're not very difficult).  They are programming questions.  Basically, you need to fill out these functions.  I'll provide comments on what they should accomplish, though they should be self explanatory.

/* First question */
// This function takes in a number and multiplies it by 7...pretty simple.
// However, you can not use the "*" (multiply) operator.  Try to make it as concise
// as possible.
int mult7(int num)
{
}

/* Second question */
// This function takes in a numerator and a denominator and must perform
// division.  This one was a little convoluted for me the first time trying to
// crack it, but it made sense in the end.  Oh yeah... you can use the "/" (divide)
// and the "*" (multiply) operators. One more thing, this is integer division, so don't
// worry about integer truncation.  Ex.  7/2 = 3 not 3.5.
int divide(int num, int den)
{
}

All right, this is suppose to be fun, so have at it, y'all.

Edit:
Topic was just called "Divide Function"...had to include the multiplication one.

~Zorb Burger

4
Projects / Re: Tony the Speeder
« on: 2008-12-13, 02:30:35 PM »
I'm not trying to downgrade you or anything, but don't you think that Benjamin Marty deserves some of the profit you make, if any?  After all, you are using his game engine.  Just a thought...

Pages: [1]