Advertisement
andreisophie

Tema 16 Sep 2019

Sep 15th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream f("SumTriunghi.in");
  6. ofstream g("SumTriunghi.out");
  7.  
  8. int n,a[100][100];
  9.  
  10. void citire()
  11. {
  12.     f>>n;
  13.     for (int i=0;i<n;i++)
  14.         for (int j=0;j<=i;j++)
  15.             f>>a[i][j];
  16. }
  17.  
  18. int drum(int l, int c)
  19. {
  20.     if (l==n-1)
  21.         return a[l][c];
  22.     return max(drum(l+1,c),drum(l+1,c+1))+a[l][c];
  23. }
  24.  
  25. int main()
  26. {
  27.     citire();
  28.     g<<drum(0,0);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement