Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream f("haromszog.be");
- int n;
- f>>n;
- int a[n+1][n+1]={0};
- for(int i=1;i<=n;i++){
- for(int j=1;j<=i;j++){
- if(i>=j)
- f>>a[i][j];
- }}
- int b[n+1][n+1]={0};
- for(int i=n;i>=1;i--)
- {
- for(int j=i;j>=1;j--)
- {
- if(i==n) b[i][j]=a[i][j];
- else if( b[i+1][j+1]>=b[i+1][j]) b[i][j]=b[i+1][j+1]+a[i][j];
- else b[i][j]=b[i+1][j]+a[i][j];
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=i;j++){
- cout<<b[i][j]<<" ";}
- cout<<endl;
- }
- cout<<endl;
- cout<<endl;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=i;j++){
- cout<<a[i][j]<<" ";}
- cout<<endl;
- }
- return 0;
- }
- ++++++++++++
- 5
- 3
- 7 5
- 1 8 6
- 5 6 4 9
- 2 4 7 10 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement