-
Notifications
You must be signed in to change notification settings - Fork 288
/
Copy pathAC_simulation_n2.cpp
43 lines (38 loc) · 934 Bytes
/
AC_simulation_n2.cpp
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
34
35
36
37
38
39
40
41
42
/*
* Author: illuz <iilluzen[at]gmail.com>
* File: AC_simulation_n2.cpp
* Create Date: 2014-12-15 14:50:13
* Descripton: simulation
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 0;
class Solution {
public:
vector<vector<int> > generate(int numRows) {
vector<vector<int> > ans(numRows);
if (numRows == 0)
return ans;
for (int i = 0; i < numRows; i++) {
ans[i].push_back(1);
for (int j = 1; j < i; j++)
ans[i].push_back(ans[i - 1][j - 1] + ans[i - 1][j]);
if (i)
ans[i].push_back(1);
}
return ans;
}
};
int main() {
int n;
Solution s;
while (cin >> n) {
vector<vector<int> > ans = s.generate(n);
for (vector<int> i : ans) {
for (int j : i)
printf("%d ", j);
puts("");
}
}
return 0;
}