Advertisement
AquaBlitz11

TASK_042 - AquaBlitz11's Solution

Dec 31st, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 35;
  6.  
  7. int dp[N][N];
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     scanf("%d", &n);
  13.     dp[0][0] = 1;
  14.     for (int i = 1; i <= n; ++i)
  15.         dp[i][0] = dp[i][i] = 1;
  16.     for (int i = 1; i < n; ++i) {
  17.         for (int j = 1; j < i; ++j)
  18.             dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
  19.     }
  20.  
  21.     for (int i = 0; i < n; ++i) {
  22.         printf("___");
  23.         for (int j = 0; j < n-1-i; ++j)
  24.             printf("__");
  25.         for (int j = 0; j <= i; ++j) {
  26.             if (j != 0)
  27.                 printf("__");
  28.             printf("%d", dp[i][j]);
  29.         }
  30.         printf("\n");
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement