#include<iostream>
#include<iomanip>
usingnamespace 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;
}
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;
}
}