Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 35;
- int dp[N][N];
- int main()
- {
- int n;
- scanf("%d", &n);
- dp[0][0] = 1;
- for (int i = 1; i <= n; ++i)
- dp[i][0] = dp[i][i] = 1;
- for (int i = 1; i < n; ++i) {
- for (int j = 1; j < i; ++j)
- dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
- }
- for (int i = 0; i < n; ++i) {
- printf("___");
- for (int j = 0; j < n-1-i; ++j)
- printf("__");
- for (int j = 0; j <= i; ++j) {
- if (j != 0)
- printf("__");
- printf("%d", dp[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement