A.cpp 537 B

1234567891011121314151617181920212223242526
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int a[21][21];
  5. a[0][0] = 1;
  6. for(int i = 0;i <= 20; i++){
  7. a[i][0] = a[i][i] = 1;
  8. }
  9. for(int i = 1; i <= 20; i++){
  10. for(int j = 1; j < i; j++){
  11. a[i][j] = a[i-1][j-1] + a[i-1][j];
  12. }
  13. }
  14. int n;
  15. while(cin >> n){
  16. for(int i = 0; i < n; i++){
  17. for(int j = 0; j < i; j++){
  18. cout << a[i][j] << " ";
  19. }
  20. cout << a[i][i] << endl;
  21. }
  22. cout << endl;
  23. }
  24. }