fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int i,j,k,n;
  6. cin>>n;
  7. int a[n][n];
  8.  
  9. for(i=0;i<n;i++)
  10. {
  11. a[i][0]=1;
  12. a[0][i]=1;
  13. }
  14.  
  15. for(i=0;i<n;i++)
  16. {
  17. for(j=0;j<n;j++)
  18. {
  19. a[i+1][j+1]=a[i+1][j]+a[i][j+1];
  20. }
  21. }
  22.  
  23. for(i=0;i<n;i++)
  24. {
  25. for(j=0;j<n;j++)
  26. {
  27. cout<<a[i][j]<<" ";
  28. }
  29. cout<<endl;
  30. }
  31. }
  32.  
Success #stdin #stdout 0s 4376KB
stdin
5
stdout
1 1 1 1 1 
1 2 3 4 5 
6 8 11 15 20 
26 34 45 60 80 
106 140 185 245 325