Paskal


SUBMITTED BY: itsDaveLad

DATE: March 9, 2016, 5:15 p.m.

FORMAT: Text only

SIZE: 803 Bytes

HITS: 581

  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. vector<vector<int>> f(int n){
  5. vector<vector<int>>mat;
  6. mat.resize(n);
  7. for(int i=0;i<mat.size();i++)
  8. mat[i].resize(i+1);
  9. for(int i=0;i<mat.size();i++){
  10. for(int j=0;j<mat[i].size();j++){
  11. if(i==0 || j==0) mat[i][j]=1;
  12. else
  13. mat[i][j]=mat[i-1][j]+mat[i-1][j-1];
  14. }
  15. }
  16. return mat;
  17. }
  18. int main() {
  19. vector<vector<int>>m;
  20. int a;
  21. cin>>a;
  22. m=f(a);
  23. for(int i=0;i<m.size();i++){
  24. for(int j=0;j<m[i].size();j++){
  25. cout<<m[i][j]<<" ";
  26. }cout<<endl;
  27. }
  28. return 0;
  29. }

comments powered by Disqus