473,466 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Thirteen Stones

In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?

Oct 20 '05 #1
23 3436
coinjo wrote:
In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?


Accept input.
Process input.
Generate output.

In other words, we won't do your homework for you. Make your best
effort, show us what you've come up with, and then we'll help.

See FAQ 5.2: http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

Oct 20 '05 #2

"coinjo" <co****@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?


Yes. Show some effort. If you actually try, and
when you get stuck, post your code with specific
questions, then we'll help. Nobody is going to
do it for you.

-Mike
Oct 20 '05 #3
coinjo wrote:
In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?


If you really can't make some progress on that question by yourself then
maybe you should consider another direction. Programming assignments
don't get much easier, its a single simple loop.

Now of course in attempting to solve this you might get stuck, that's
expected, but you should be able to at least attempt a solution by yourself.

john
Oct 20 '05 #4
coinjo wrote:

In "Thirteen Stones" game, two players alternately take 1, 2, or 3
stones from a pile of 13 stones until no stones are left. The last
player to pick up a stone is the winner.

I need to make a program that simulates the "Thirteen stones" game.
My program should alternately ask the players to select how many stones
they wish to remove from the pile. If the selection is valid (1, 2, or
3 stones), the selected number of stones should be removed from the
pile. If a player enters an invalid number of stones, the program
should display an error message and ask the player to select again.
Continue play until no stones are left, and display a message
indicating the winner.

Input: Number of stones (1, 2, or 3) chosen on each turn
Output: A message declaring the winner.

Any hints please?


It boils down to having an int variable, maybe you call it 'pile',
that is counted down, where users tell the program how much it
has to count down. When 'pile' reaches 0, the user doing the last
input is the winner.
--
Karl Heinz Buchegger
kb******@gascad.at
Oct 20 '05 #5
#include<iostream.h>
void main()
{
char selection;
int stones=13;
int done1=0;
while(stones>0 && done1!=1)
{
if(stones>0)
{
selection=0;
cout<<"Player 1 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
stones=stones-1;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>1)
stones=stones-2;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
stones=stones-3;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(stones==0)
{
cout<<"Player 1 Wins"<<endl;
done1=1;
}
}

if(stones>0 && done1!=1)
{cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
{
stones=stones-1;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>10)
{
stones=stones-2;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
{
stones=stones-3;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(stones==0)
{
cout<<"Player 2 wins"<<endl;
done1=1;
}

}
}
}

This is the best i can come up with. But there are problems in its
output. When i constantly enter 1. It should stop at player 1 wins but
it stops at player 2 wins. Now that i have tried the code. Can anyone
help me?

Oct 20 '05 #6
coinjo wrote:
#include<iostream.h>
void main()
{
char selection;
int stones=13;
int done1=0;
while(stones>0 && done1!=1)
{
if(stones>0)
{
selection=0;
cout<<"Player 1 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
stones=stones-1;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>1)
stones=stones-2;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
stones=stones-3;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(stones==0)
{
cout<<"Player 1 Wins"<<endl;
done1=1;
}
}

if(stones>0 && done1!=1)
{cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
{
stones=stones-1;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>10)
{
stones=stones-2;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
{
stones=stones-3;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(stones==0)
{
cout<<"Player 2 wins"<<endl;
done1=1;
}

}
}
}

This is the best i can come up with. But there are problems in its
output. When i constantly enter 1. It should stop at player 1 wins but
it stops at player 2 wins. Now that i have tried the code. Can anyone
help me?


Here's a more readable version of the program:

#include<iostream> // N.B., iostream.h is deprecated
using namespace std;

int main() // N.B., not void main()
{
char selection;
int stones=13;
int done1=0; // Could be a bool instead of an int
while(stones>0 && done1!=1)
{
if(stones>0) // Redundant. The while condition ensures that
// this is true.
{
selection=0;
cout<<"Player 1 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0) // Redundant
stones=stones-1; // stones -= 1; is more
compact
else
{ // This else condition will never be reached
// because stones will always be > 0. If it were
reached,
// however, it would ask the user for input but not
test
// to see if the input is 1 again. The same thing
applies
// to the other else's below, except they can be
reached!

cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(selection=='2') // Should be: else if( selection=='2' )
{
if(stones>1)
stones=stones-2;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(selection=='3') // Use else if here, too
{
if(stones>2)
stones=stones-3;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;

}
}

if(stones==0)
{
cout<<"Player 1 Wins"<<endl;
done1=1;
// continue; // Would skip the next part
}
}

if(stones>0 && done1!=1)
{
cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0) // Redundant
{
stones=stones-1;
}

else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;

}
}

if(selection=='2')
{
if(stones>10)
{
stones=stones-2;
}

else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(selection=='3')
{
if(stones>2)
{
stones=stones-3;
}

else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(stones==0)
{
cout<<"Player 2 wins"<<endl;
done1=1;
}
}
}
return 0;
}
On a cursory reading, I'd guess that the faulty error checking is your
problem. If you enter the thirteen 1's without error, it might work
(though I didn't test it). What you need to do is either learn to use
the debugger that is undoubtedly included with your development
environment, or more simply put some extra cout's in the code so you
can tell what the program is doing at each point.

Cheers! --M

Oct 20 '05 #7
coinjo wrote:
if(stones>0 && done1!=1)
{cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
{
stones=stones-1;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}

if(selection=='2')
{
if(stones>10)
10 ???
{
stones=stones-2;
} ....
This is the best i can come up with. But there are problems in its
output.
My I suggest you output the number of stones left on the pile
before you ask each player for his turn?
When i constantly enter 1. It should stop at player 1 wins but
it stops at player 2 wins. Now that i have tried the code. Can anyone
help me?


If I run your program and always enter 1, then the program ends with
'Player 1 wins'

Hint: it is always a good idea, to output a few intermediate results.
Eg. before you ask each player for his choice, show him the number
of stones left on the pile.
Also: After getting an input from the user, it is also a good idea
to report to the user what the program has read and what it does with that
input.
eg.

if( stones > 0 )
{
selection = 0;
cout << "There are " << stones << " stones left on the pile.\n";
cout << "Player 1 Enter Your Selection (1-3)" << endl;

cin >> selection;
if( selection == '1' )
{
if( stones > 0 )
{
cout << "Player 1 choosed to take 1 stone.\n";
stones = stones-1;
}
else
{
...

This not only reduces the confusion for the person sitting infront
of the computer. It also allows the devloper of the program to monitor
if things go the way he intended them to go.

Hint 2:
A few whitespace characters in the source code can do wonders in readability.
Indenting the code is not only a luxary, but is also a good tool in fighting
bugs (although that might have happend during your code posting)

--
Karl Heinz Buchegger
kb******@gascad.at
Oct 20 '05 #8
"coinjo" <co****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
#include<iostream.h>
void main()
{
char selection;
int stones=13;
int done1=0;
while(stones>0 && done1!=1)
{
if(stones>0)
{
selection=0;
cout<<"Player 1 Enter Your Selection"<<endl;
cin>>selection; if(selection=='1')
{
if(stones>0)
stones=stones-1;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>1)
stones=stones-2;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
stones=stones-3;
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
Why are you making selection a character instead of an int? Would make it a
lot easier for you.

int selection;
....
cin >> selection;

Now you can get rid of your 3 if statments and do a little math.

if ( stones >= selection )
stones -= selection;
else
cout << "Invalid Selection" << std::endl;

You'll need to change your logic there, beucase your
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}

isn't enough. You're having the user reinput the selection, but you've
already passed up where you do anything with it. Perhaps you might want to
look at a while block...

while ( selection = 0 && stones > 0 )
{
// do input here and checking and subtraction, etc...
// if they selected an invalid amount set selection to 0
// so they have to put it in again
}
if(stones==0)
{
cout<<"Player 1 Wins"<<endl;
done1=1;
}
}

if(stones>0 && done1!=1)
{cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
{
stones=stones-1;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='2')
{
if(stones>10)
{
stones=stones-2;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(selection=='3')
{
if(stones>2)
{
stones=stones-3;
}
else
{
cout<<"Invalid Selection. Enter Again"<<endl;
cin>>selection;
}
}
if(stones==0)
{
cout<<"Player 2 wins"<<endl;
done1=1;
}

}
}
}

This is the best i can come up with. But there are problems in its
output. When i constantly enter 1. It should stop at player 1 wins but
it stops at player 2 wins. Now that i have tried the code. Can anyone
help me?


You are duplicating code for the players. You do input for 1, then the
other. You don't need to. The exact same logic applies in both cases. The
only thing that changes is the player number.

int PlayerNumber = 1;
while(stones>0 && done1!=1)
{
// blah blah
// input, see if won, etc.. here. at end:

if ( PlayerNumber == 1 }
PlayerNumber = 2;
else
PlayerNumber = 1;

// If you want you can use trinary for that instead:
// PlayerNumber = ( PlayerNumber == 1 ? 2 : 1 );
}
Oct 20 '05 #9
Please suggest changes in the program posted by mlimber and also please
post the full code again as it is very hard to understand your
suggestions.

Oct 20 '05 #10
coinjo wrote:
Please suggest changes in the program posted by mlimber and also please
post the full code again as it is very hard to understand your
suggestions.


We're not going to do your homework for you. Read the post again; I
think it is sufficiently clear. If you disagree, ask specific questions
about it. More importantly, note that this discussion is not concerned
with the C++ language proper and is thus off topic (as I've noted in
the changed subject line). Please ask in one of the groups I mentioned
in my previous post.

Cheers! --M

PS, You should quote the post you're referring to and put your comments
*below* it. Not everyone is using Google groups to read these messages,
and quoting makes it easier for them to follow the discussion. (To
quote with Google, click on "show options" beside the message you want
to respond to, and then click "Reply" in the revealed header.)

Oct 20 '05 #11
Can anybody tell me what does stones -= 1 means?

Oct 20 '05 #12
#include<iostream.h>
void main()

{
char selection;
int stones=13;
int done1=0;
while(stones>0 && done1!=1)
{
if(stones>0)
{
selection=0;
cout<<"Player 1 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
if(stones>0)
stones=stones-1;
}
else if(selection=='2')
{
if(stones>1)
stones=stones-2;
}
else if(selection=='3')
{
if(stones>2)
stones=stones-3;
}
if(stones==0)
{
cout<<"Player 1 Wins"<<endl;
done1=1;

}
}
if(stones>0 && done1!=1)
{
cout<<"Player 2 Enter Your Selection"<<endl;
cin>>selection;
if(selection=='1')
{
stones=stones-1;
}
if(selection=='2')
{
if(stones>10)
{
stones=stones-2;
}
}
if(selection=='3')
{
if(stones>2)
{
stones=stones-3;
}
}
if(stones==0)
{
cout<<"Player 2 wins"<<endl;
done1=1;
}
}
}
}

i have edited the code somewhat and removed the error part of the
program. But still the program only works when i enter 1's and not for
two's or three's. Please suggest changes in the above code.

Oct 21 '05 #13
#include<iostream.h>
void main()
{
int selection=0;
int stones=13;
int player=0;

while(stones>0)

{

cout<<"Enter Player"<<endl;

cin>>player;

{

cout<<"Enter Your Selection"<<endl;

cin>>selection;

if(stones>=selection)

{

stones=stones-selection;

}

else

cout<<"Invalid Selestion"<<endl;

}

if(stones==0)

{

if(player==1)

{

cout<<"Player 1 Wins!"<<endl;

}

else

cout<<"Player 2 Wins!"<<endl;

}

}
}
Thanks to all of you for your generous help. I was finally able to make
the program work with the above syntax. Please Check it and tell me if
you find any errors in it.

Oct 21 '05 #14
"coinjo" <co****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
#include<iostream.h>
void main()
{
int selection=0;
int stones=13;
int player=0;

while(stones>0)

{

cout<<"Enter Player"<<endl;

cin>>player;

{

cout<<"Enter Your Selection"<<endl;

cin>>selection;

if(stones>=selection)

{

stones=stones-selection;

}

else

cout<<"Invalid Selestion"<<endl;

}

if(stones==0)

{

if(player==1)

{

cout<<"Player 1 Wins!"<<endl;

}

else

cout<<"Player 2 Wins!"<<endl;

}

}
}
Thanks to all of you for your generous help. I was finally able to make
the program work with the above syntax. Please Check it and tell me if
you find any errors in it.


If you provide here a complete working program that does what you want, I'll
show you how I would do it.

You should probably be posting in:
alt.comp.lang.learn.c-c++

as there is a lot more tolerance there for beginner questions on language
syntax.
Oct 21 '05 #15
"coinjo" <co****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Can anybody tell me what does stones -= 1 means?


stones = stones - 1;
stones -= 1;

Those two lines do the exact same thing. As would:

stones = stones + x;
stones += x;

+= and -= are just a shortcut way of doing it and is quite common in use.
Oct 21 '05 #16

"coinjo" <co****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Can anybody tell me what does stones -= 1 means?


It's the same as:

stones = stones - 1;

Similar operators are:

x += y /* x = x + y */
x *= y /* x = x * y */
x /= y /* x = x / y */
Also equivalent to

stones -= 1

is

--stones

-Mike
Oct 21 '05 #17

"coinjo" <co****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
#include<iostream.h>
#include <iostream> /* declares 'cin' and 'cout' */
#include <ostream> /* declares 'endl' */

using namespace std; /* all library names (except macros)
are defined in namespace 'std' */
void main()
int main() /* main() is *required* to have
return type 'int' */
{
int selection=0;
int stones=13;
int player=0;

while(stones>0)

{

cout<<"Enter Player"<<endl;

cin>>player;
What happens if I type "abc" at this prompt?

{

cout<<"Enter Your Selection"<<endl;

cin>>selection;
What happens if I type "abc" at this prompt?

if(stones>=selection)

{

stones=stones-selection;

}

else

cout<<"Invalid Selestion"<<endl;

}

if(stones==0)

{

if(player==1)

{

cout<<"Player 1 Wins!"<<endl;

}

else

cout<<"Player 2 Wins!"<<endl;

}

}
return 0; /* optional, but imo 'good practice' */
}
Please indent your code, it's hard to read otherwise.


Thanks to all of you for your generous help. I was finally able to make
the program work with the above syntax. Please Check it and tell me if
you find any errors in it.


See above.

-Mike
Oct 21 '05 #18
Mike Wahler wrote:

#include <iostream> /* declares 'cin' and 'cout' */
#include <ostream> /* declares 'endl' */

[snip]

There's no need to include ostream if iostream is already included.

Cheers! --M

Oct 21 '05 #19
Mike Wahler wrote:
"coinjo" <co****@gmail.com> wrote in message
cout<<"Enter Player"<<endl;

cin>>player;


What happens if I type "abc" at this prompt?

[snip]

One more comment for the OP: what happens if you enter any other number
(e.g., -10, 42000, 8675309)? You shouldn't be letting the user control
this variable since the rules of the game mandate that turns alternate
between two and only two players. Instead, you should put the logic for
the players in a loop:

while( stones > 0 )
{
for( int player = 1; player <= 2; player++ )
{
// Put stone selection logic here
}
}

Cheers! --M

Oct 21 '05 #20
* mlimber:
Mike Wahler wrote:

#include <iostream> /* declares 'cin' and 'cout' */
#include <ostream> /* declares 'endl' */

[snip]

There's no need to include ostream if iostream is already included.


Formally there is, or might be, depending on one's faith in intentions instead
of the Literal Word (TM) of the standard.

<iostream> only forward-declares the eight or so standard iostream objects.

Practically I doubt there is any compiler where <iostream> isn't enough,
because it would break so much code to require <ostream> in addition, but just
to help people understand that compilesWithMyCompiler != isStandard, I usually
add <ostream> in my examples.
Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 21 '05 #21
coinjo wrote:

#include<iostream.h>
void main()
{
int selection=0;
int stones=13;
int player=0;

while(stones>0)

{

cout<<"Enter Player"<<endl;

cin>>player;

{

cout<<"Enter Your Selection"<<endl;

cin>>selection;

if(stones>=selection)

{

stones=stones-selection;

}

else

cout<<"Invalid Selestion"<<endl;

}

if(stones==0)

{

if(player==1)

{

cout<<"Player 1 Wins!"<<endl;

}

else

cout<<"Player 2 Wins!"<<endl;

}

}
}

Thanks to all of you for your generous help. I was finally able to make
the program work with the above syntax. Please Check it and tell me if
you find any errors in it.


Well. First of all, as already noted, when the program is run
your users have no idea of how many stones are left on the pile.
Actually, the users *never* see (unless they study your code), how
many piles are there on the pile (eg. in europe this game is played
with 21 stones :-)

But then, try the following:
start out with 13 stones. Let the porgram ask user 1 for his choice.
And now user 1 wants 13 stones. user 1 wins. :-)

Start with fixing that. (A user cannot draw more then 3 or less then 1 stone,
it is a simple if)

All other things already mentioned, like inputting 'abc' can wait
until you get this right.

Also there seems to be something wrong with your overall game logic.
How come the program asks *me* whose turn it is. Shouldn't the program
know this? Otherwise I always enter 0 when the program asks me for the
player, and player 1 thus always wins.

If you need a variable to toggle between 0 and 1 you can use:

player = 1 - player;

each time that assignment is executed, it changes from 0 to 1 or vice versa
depending on the previous state.

I know, programmers are the worst testing persons. Nevertheless all of the
above mentioned things are simple ones. You should have, no, you *must* have
found them all by yourself.

--
Karl Heinz Buchegger
kb******@gascad.at
Oct 21 '05 #22
Alf P. Steinbach wrote:
* mlimber:
Mike Wahler wrote:

#include <iostream> /* declares 'cin' and 'cout' */
#include <ostream> /* declares 'endl' */

[snip]

There's no need to include ostream if iostream is already included.


Formally there is, or might be, depending on one's faith in
intentions instead of the Literal Word (TM) of the standard.

There's supposed to be an outstanding issue before the committee on
this subject (or there was a couple years ago). I'm sure what the
current status is.

Brian
Oct 21 '05 #23

"mlimber" <ml*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Mike Wahler wrote:

#include <iostream> /* declares 'cin' and 'cout' */
#include <ostream> /* declares 'endl' */

[snip]

There's no need to include ostream if iostream is already included.


Not true. 'std::endl' is only guaranteed to be declared
by <ostream>. It might indeed be indirectly declared with
only <iostream> (via headers including headers), but you have
no guarantee of that from the standard language.

-Mike
Oct 21 '05 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NotAsDumbAsILook | last post by:
I'm using NetBeans 3.5.1. Why doesn't this work? Referenced class: public class MyClass { ... ...
17
by: meital | last post by:
There are three kinds of stones: red,green and blue. Each cell of the array contains one stone. The array needs to be sorted so that all the red stones will come first, then the blue ones and...
2
by: ALi Shaikh | last post by:
I already did the game once and it works but now I need to change it to add a function that will make the computer take player 1 turn and always win. heres the original #include<iostream.h> ...
10
by: j0k3r | last post by:
Hiya, i'm trying to create a Go (the game) simulation in PHP, the problem is how to mark dead stones. each stone has some liberties wich are the empty territories nearby, when a group of stones...
1
by: Leiram | last post by:
I am trying to write a game where there is 13 stones and you play against the computer to make sure that you don't take the last stone. You or the computer (depending on the turn) is allowed to take...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.