SHARE
TWEET

Tema 16 Sep 2019

andreisophie Sep 15th, 2019 (edited) 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top