Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("SumTriunghi.in");
- ofstream g("SumTriunghi.out");
- int n,a[100][100];
- void citire()
- {
- f>>n;
- for (int i=0;i<n;i++)
- for (int j=0;j<=i;j++)
- f>>a[i][j];
- }
- int drum(int l, int c)
- {
- if (l==n-1)
- return a[l][c];
- return max(drum(l+1,c),drum(l+1,c+1))+a[l][c];
- }
- int main()
- {
- citire();
- g<<drum(0,0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement