Advertisement
rotti321

Sim BAC 2017 SII 5

Mar 9th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. ///BAC 2017 simulare II 5
  2. #include <iostream>
  3. /**Ex: n=4
  4. 4 4 4 4
  5. 15 11 7 3
  6. 35 20 9 2
  7. 65 30 10 1
  8. */
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. int n,a[21][21],x,i,j;
  14. cin>>n;
  15.  
  16. for(i=1;i<=n;i++)
  17. {
  18. a[1][i]=n;
  19. a[i][n]=n-i+1;
  20.  
  21. }
  22. for(i=2;i<=n;i++)
  23. {
  24. for(j=n-1;j>=1;j--)
  25. {
  26. a[i][j]=a[i-1][j]+a[i][j+1];
  27. }
  28. }
  29. for(i=1;i<=n;i++)
  30. {
  31. for(j=1;j<=n;j++)
  32. {
  33. cout<<a[i][j]<<"\t ";
  34. }
  35. cout<<endl;
  36. }
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement