fork(1) download
  1. #include<iostream>;
  2. #include<cstdlib>;
  3. using namespace std;
  4.  
  5. int fact(int n) {
  6. int k = 1;
  7. if (n == 0)
  8. return 1;
  9. for (int i = 1; i <= n; i++)
  10. k = k*i;
  11. return k;
  12. }
  13. void func(int n) {
  14. for (int j = 0; j < n; j++) {
  15. for (int i = 0; i <= j; i++)
  16. cout << (fact(j) / (fact(i)*fact(j - i))) << " ";
  17. cout << endl;
  18. }
  19. }
  20.  
  21. int main() {
  22. int n;
  23. cin >> n;
  24. func(n);
  25. system("pause");
  26. }
Success #stdin #stdout #stderr 0s 3416KB
stdin
14
stdout
1 
1 1 
1 2 1 
1 3 3 1 
1 4 6 4 1 
1 5 10 10 5 1 
1 6 15 20 15 6 1 
1 7 21 35 35 21 7 1 
1 8 28 56 70 56 28 8 1 
1 9 36 84 126 126 84 36 9 1 
1 10 45 120 210 252 210 120 45 10 1 
1 11 55 165 330 462 462 330 165 55 11 1 
1 12 66 220 495 792 924 792 495 220 66 12 1 
1 4 24 88 221 399 532 532 399 221 88 24 4 1 
stderr
sh: 1: pause: not found