#include using namespace std; // Reads in a value 'n', then prints out the Hankel // matrix for that value // e.g. first row: // 1 2 3 ... n // 2 3 4 ... n+1 // ... // n n+1 ... 2n-1 // Make the columns line up nicely. Assume n<=50. int main33() { // Get n value from the user int n; cout << "Please enter n: "; cin >> n; // Produce Hankel matrix for n for (int row = 1; row <= n; row++) { // Produce i'th row for (int col=1; col <= n; col++) { /* * Produce (row,col) value in 2 spaces */ // Calculate output value int val = row + col - 1; // Produce extra space if value is "1-wide" if (val < 10) { cout << " "; } // Output the value cout << val << " "; } cout << endl; } return 0; }