fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. unsigned binCoef(unsigned n, unsigned m) {
  7. if (n == 0 || m == 0)
  8. return 1;
  9. else
  10. return binCoef(n - 1, m) + binCoef(n, m- 1);
  11. }
  12.  
  13. int main() {
  14. unsigned n = 7, m = 6;
  15. vector<vector<unsigned>> arr(n);
  16. for (auto &a: arr) a = vector<unsigned>(m);
  17.  
  18. for (size_t i = 0; i < n; ++i)
  19. for (size_t j = 0; j < m; ++j)
  20. arr[i][j] = binCoef(i, j);
  21.  
  22. for (auto a: arr) {
  23. for (auto b: a) cout << b << " ";
  24. cout << endl;
  25. }
  26. }
  27.  
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
1 1 1 1 1 1 
1 2 3 4 5 6 
1 3 6 10 15 21 
1 4 10 20 35 56 
1 5 15 35 70 126 
1 6 21 56 126 252 
1 7 28 84 210 462