I am having a problem of my output coming out lined up in a nice column. It's supposed to line up with each "S" in the sides. Also, if I iterate the loop another time it will count the number of triples from the past loop instead of doing it independently. For example, the first loop had 8 triples and the second on has 4. The number of triples will be 10 instead of 4. Any help?
#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
int limit;
int triples = 0;
char input;
do
{
cout << endl;
cout << "Enter upper limit for each side of the triangle: ";
cin >> limit;
cout << "Side 1 Side 2 Side3" << endl;
for (int a = 0; a <= limit; a++)
{
for (int b = a + 1; b <= limit; b++)
{
for (int c = b + 1; c <= limit; c++)
{
if (a*a + b * b == c * c) {
cout << a << setw(5) << b << setw(5) << c << endl;
triples++;
}
}
}
}
cout << "A total of " << triples << " triples were found." << endl;
cout << "Y or y to continue, anything else quits " << endl;
cin >> input;
} while (input == 'y' || input == 'Y');
}