Code:

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
int m, mm;
double xm;
int i, j;
int c;
//Get candidate-table dimensions
cout << "This program generates Pythagorean candidate numbers in a table.\n\n";
cout << "Type the absolute P-candidate maximum M:\n";
cin >> m;
xm = m+1;
mm = sqrt(xm/2.);
cout << "The row/column size of the candidate table is: " << mm << "\n\n\n";
for( j = 2; j < mm; j++ )
{
cout << setw(5) << j;
}
cout << "\n\n";
//Generates table
for( i = 1; i < mm - 1; i++ )
{
cout << "R= " << setw(2) << i;
for( j = 2; j <= i; j++ )
{
c = (( i * i ) + ( j * j ));
cout << setw(5) << c;
}
cout << "\n";
}
cout << endl;
system( "Pause" );
return 0;
} //end main