Skip to content

Instantly share code, notes, and snippets.

@yelvert
Created April 19, 2011 21:00
Show Gist options
  • Save yelvert/929642 to your computer and use it in GitHub Desktop.
Save yelvert/929642 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int min = 0;
int max;
while (max < 1) {
cout << "Table from 0 through (enter 1-10): ";
cin >> max;
if (max < 1) {
cout << "Oops!" << endl;
}
}
cout << setw(3) << endl << "N";
for (int i=min;i<=max;i++) {
cout << setw(3) << i;
}
cout << setw(3) << endl;
for (int row=min;row<=max;row++) {
cout << setw(3) << row;
for (int col=min;col<=max;col++) {
cout << setw(3) << row*col;
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment