Guess the output
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
Any language, any type of algorithm.. post it and guess at others.. I'll start:
Java:
for (int i=0;i<(new Date()).getMonth();i++) {
System.out.print(i/2);
}
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
At 10/5/01 04:04 PM, UnclePecos wrote: Any language, any type of algorithm.. post it and guess at others.. I'll start:
Java:
for (int i=0;i<(new Date()).getMonth();i++) {
System.out.print(i/2);
}
Hmmm. At a guess, this would print something like:
0
0.5
1
... intervals of 0.5 up to
4.5
(assuming that the month is October).
At least, I think that's how it would work (with my complete lack of knowledge with Java).....
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 10/6/01 08:33 AM, liljim wrote: Hmmm. At a guess, this would print something like:
0
0.5
1
... intervals of 0.5 up to
4.5
(assuming that the month is October).
At least, I think that's how it would work (with my complete lack of knowledge with Java).....
Nope! Any other guesses?
- LordAba
-
LordAba
- Member since: Nov. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
At 10/7/01 08:08 PM, UnclePecos wrote:At 10/6/01 08:33 AM, liljim wrote: Hmmm. At a guess, this would print something like:Nope! Any other guesses?
0
0.5
1
... intervals of 0.5 up to
4.5
(assuming that the month is October).
At least, I think that's how it would work (with my complete lack of knowledge with Java).....
Either it wouldn't work, or it'll print out lilJim's answer, only all on one line.
What may man within him hide, though angel on the outward side.
- LordAba
-
LordAba
- Member since: Nov. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
What does this function do in C++?
static int comp(const void *a, const void *b)
{
return strcmp(*(char **)a, *(char **)b);
}
What may man within him hide, though angel on the outward side.
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 10/7/01 11:06 PM, Lord_Aba wrote: Either it wouldn't work, or it'll print out lilJim's answer, only all on one line.
Wrong!
Yes, it would print it out all on one line, but the numbers would be different. First of all, division ignores the remainder and only returns integers. So the output would be 001122.. and so on.
and Date.getMonth() would return the current month number - 1, or 9.
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 10/7/01 11:22 PM, Lord_Aba wrote: What does this function do in C++?
static int comp(const void *a, const void *b)
{
return strcmp(*(char **)a, *(char **)b);
}
Pointers to a and b are casted to char pointers and compaired as to which one is smaller or comes first in alphabetical order. But I'm not so sure that an int is returned, perhaps it's a bool.
My C++ is a bit rusty, so maybe I'm a little off... I don't know why void is used in the parameters being passed in either... o_O
- RancidScammerDude
-
RancidScammerDude
- Member since: Jul. 27, 2001
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Hmm, I cant teach html in BBS with out it messin up..

