This is the problem
You are walking along on a nice sunny day and stumble upon a very odd bag of beans. This bag contains a few black beans and a few white beans. You want to use the bag, but you don't have a use for the beans. Therefore, you decide to take all the beans out. Being an odd bag, you discover only two beans can be removed at a time. Furthermore, the following rules apply:
If both the beans you remove are the same color, one more black bean magically appears in the bag.
If the beans you remove differ in color, one more white bean magically appears in the bag.
Since you are a curious computer science student, you decide to write a program. This program will input the number of black beans and the number of white beans in the bag. The output of this program will be the color of the last bean in the bag.
this is what I have so far
Code:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
void main()
{
srand((unsigned)time(NULL));
int blk, white, ran, ran1;
cout<<"How many black beans ";
cin>>blk;
cout<<"How many white bean ";
cin>>white;
do{
ran=rand()%2;
ran1=rand()%2;
if (ran == ran1)
blk += 1;
if (ran != ran1)
white += 1;
if (ran = 1)
blk -=1;
if (ran = 2)
white -=1;
}while (blk == 0 || white == 0);
cout<<"Black : "<<blk<<" White : "<<white<<endl;
getch();
}
my problem is that none of the numbers go to zero
Thanks Joe