|
-
March 28th, 1999, 08:00 PM
#1
Whoa, whoa, whoa ...
Good day guys!,
I'm quite surprised by the number of responses for my "little
brain exercise". I hope you won't get into a point realizing
that you have just wasted your highly-paid time.
Nobody is supposed to go home or be hired. In the first place,
my only purpose for posting this problem is to gather the (as many as
possible) valid answers, and not the BEST solution.
Please leave the validation and testing of your suggestions for me.
Oh, you might want to ask were would I use this, ok, i'm just thinking
if I could include this problem in the battery test for our applicants
in a programmer trainee position. And I don't think you're interested
with the job-opening, are you?
Sorry if i've scratched a match in a dry wooden forest.
Thanks for doing your job as fee-free-gurus.
-
March 28th, 1999, 09:31 PM
#2
Please don't use this in an interview
Ok, I've allowed myself to be drawn into this conversation for the last time. Please, please, don't use this sort of question in an interview. You want to hire motivated, creative individuals. Whether they know this sort of trivia is, IMHO, irrelevant. I'd much rather hire someone with some fire in his belly than some know-it-all who's going to win the next round of Jeopardy. Sure, ask him/her what xor/xor/xor will do, and observe his/her reaction. If it's a blank stare, deduct points. If it's anything else, add points. Again, JMHO. Sorry!
-
March 28th, 1999, 11:54 PM
#3
Re: Please don't use this in an interview
Ok, the suggestion will be considered. Thanks.
But, I really don't intend to use it as an interview question,
I prefer including it,I bet you won't disagree, in a written exam.
-
March 29th, 1999, 09:35 AM
#4
Here's another version !The only one that is to spec.!
As MS compilers allow inline assembly I thought it proper to include an example,
it's actually more within spec than any other solution that's been posted as it
truly only uses two variables and only two cpu registers.
About using it for interviews, IMHO YES, if the person is going to expected to
think and use the tools that are available. Would you use a sledg hammer to crack
nuts when a nutcracker is available ?
regards
Hans Wedemeyer
#include <stdlib.h>
void main( int argc, char* argv[] )
{
int a = 7;
int b = 9;
// did user supply new values ?
if ( argc > 1 && argc == 3 ) //expect two args a followed by b
{
a = atoi(argv[1]);
b = atoi(argv[2]);
}
printf("a=%d b=%d\n",a,b);
_asm {
mov eax,a
mov ebx,b
xchg eax,ebx
mov a,eax
mov b,ebx
}
printf("a=%d b=%d\n",a,b); // within spec. but limited to 2gig
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|