How to get same number in all the bags.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<iomanip>
using namespace std;


int main()
{
	int tries = 1;
	int digit;
	int a=11, b=6, c=7;
	cout << "Enter number of toothpicks in each of the stacks" << endl;
	cin >> a >> b >> c;
	cout << setw(21) << "Stack:" << setw(5) << "A" << setw(5) << "B" << setw(5) << "C" << endl;
	cout << "Number of Toothpicks:" << setw(5) << a << setw(5) << b << setw(5) << c << endl;
	while (tries<1)
	{
		if ((a + b + c) % 3 == 0)
		{
			(a + b + c) / 3 == digit;
			a == digit;
			b == digit;
			c == digit;
			
			cout << setw(21) << "Stack:" << setw(5) << "A" << setw(5) << "B" << setw(5) << "C" << endl;
			cout << "Number of Toothpicks:" << setw(5) << a << setw(5) << b << setw(5) << c << endl;
		}
	}
	
	system("pause");
	return 0;
}
Last edited on
tries=1 and stopping a fix value.So
1
2
3
4
5
6
7
8
9
10
11
12
13
while (tries<1)
	{
		if ((a + b + c) % 3 == 0)
		{
			(a + b + c) / 3 == digit;
			a == digit;
			b == digit;
			c == digit;
			
			cout << setw(21) << "Stack:" << setw(5) << "A" << setw(5) << "B" << setw(5) << "C" << endl;
			cout << "Number of Toothpicks:" << setw(5) << a << setw(5) << b << setw(5) << c << endl;
		}
	}

is staying invalid.Try it:
1
2
3
4
5
6
7
8
9
10
11
12
13
while (tries==1)//or if(tries==1)
	{
		if ((a + b + c) % 3 == 0)
		{
			(a + b + c) / 3 == digit;
			a == digit;
			b == digit;
			c == digit;
			
			cout << setw(21) << "Stack:" << setw(5) << "A" << setw(5) << "B" << setw(5) << "C" << endl;
			cout << "Number of Toothpicks:" << setw(5) << a << setw(5) << b << setw(5) << c << endl;
		}
	}
It is not working.
Topic archived. No new replies allowed.