Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int answer = 0;
- int h, w;
- void find_a_way(int *array[], int count, int pos_x, int pos_y){
- count = count + array[pos_x][pos_y];
- if((pos_x!=h) || (pos_y!=w)) {
- if(pos_x!=::h){
- find_a_way(array, count, pos_x+1, pos_y);
- };
- if(pos_y!=w){
- find_a_way(array, count, pos_x, pos_y+1);
- };
- }
- else{
- if(count>::answer){
- ::answer = count;
- };
- };
- }
- int main ()
- {
- freopen("/Users/maksimgolish/Desktop/text.txt", "r", stdin);
- freopen("/Users/maksimgolish/Desktop/answer.txt", "w", stdout);
- cin>>::h>>::w;
- int** field;
- field = new int*[h];
- for(int i=0; i<w; i++){
- field[i]=new int[w];
- };
- for(int i=0; i<h, i++;){
- for(int j=0; j<w; j++){
- cin>>field[w][h];
- }
- };
- find_a_way(field, 0, 0, h);
- cout<<::answer;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement