-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulttable.cpp
More file actions
33 lines (28 loc) · 726 Bytes
/
multtable.cpp
File metadata and controls
33 lines (28 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
(c) Sergio Morales 2013
CodeEval Challenge: Multiplication Tables
Date Solved: 12/23/13
**/
#include <iostream>
#include <iomanip>
using namespace std;
int main( int argc, char** argv) {
// define multiplication table as an array of array
const int SIZE = 12;
int** mtable = new int*[SIZE];
for(int p = 0; p < SIZE; ++p) {
mtable[p] = new int[SIZE];
}
// populate table
for(int i = 0; i < SIZE; ++i) {
for(int j = 0; j < SIZE; ++j) {
mtable[i][j] = (i+1)*(j+1);
}
}
for(int i = 0; i < SIZE; ++i) {
for(int j = 0; j < SIZE; ++j) {
cout << setw(4) << mtable[i][j];
}
cout << endl;
}
}