forked from shikharkohli/c---files
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexun09.cpp
More file actions
executable file
·57 lines (49 loc) · 779 Bytes
/
exun09.cpp
File metadata and controls
executable file
·57 lines (49 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//eXuN 09 question 6 incomplete
#include<iostream>
#include<stdio.h>
using namespace std;
int path(int arr[][10],int n,int i,int j)
{
if(i!=n && j!=n)
{
if((arr[i][j+1]-arr[i][j])>(arr[i+1][j]-arr[i][j]))
{
cout<<"->("<<i<<","<<j<<")";
path(arr,n,i+1,j);
}
else
{
cout<<"->("<<i<<","<<j<<")";
if(j==n-1)
{
path(arr,n,i+1,j);
}
else
path(arr,n,i,j+1);
}
}
}
int main()
{
int arr[10][10];
int i,j,n;
cout<<"Enter the value for n ";
cin>>n;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d ",&arr[i][j]);
}
printf("\n");
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<arr[i][j]<<" ";
cout<<endl;
}
cout<<endl;//int sum=0;
path(arr,n,0,0);cout<<"->("<<n-1<<","<<j-1<<")"<<endl;
return 0;
}