Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///BAC 2017 simulare II 5
- #include <iostream>
- /**Ex: n=4
- 4 4 4 4
- 15 11 7 3
- 35 20 9 2
- 65 30 10 1
- */
- using namespace std;
- int main()
- {
- int n,a[21][21],x,i,j;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- a[1][i]=n;
- a[i][n]=n-i+1;
- }
- for(i=2;i<=n;i++)
- {
- for(j=n-1;j>=1;j--)
- {
- a[i][j]=a[i-1][j]+a[i][j+1];
- }
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- cout<<a[i][j]<<"\t ";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement