Scratchpad

If you are new to Scratchpad, and want full access as a Scratchpad editor, create an account!
If you already have an account, log in and have fun!!

READ MORE

Scratchpad
Advertisement
  1. include <iostream>
  2. include <cstdio>
  3. include <fstream>

using namespace std;

int suma(int *tab, int n){ int sum = 0;

for(int i=0; i<n; i++){ sum += tab[i]; }

return sum; }


using namespace std; int main(){ ifstream fi; fi.open("dane.txt"); int n; fi >> n; int tab[n][n];

for(int x=0; x<n; x++){ for(int y=0; y<n; y++){ fi >> tab[y][x]; } }

for(int x=1; x<n; x++){ for(int y=0; y<n; y++){ for(int i=-1; i<2; i++){ int maks = 0; if(y+i>=0 && y+i<n){ maks = max(tab[x][y] + tab[x-1][y+i], maks); }else continue; tab[x][y] = maks; } } }


for(int x=0; x<n; x++){ for(int y=0; y<n; y++){ cout << tab[x][y] << "\t"; } cout << endl; }

system("pause"); return 0; }

Advertisement