-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem18.c
More file actions
38 lines (29 loc) · 737 Bytes
/
Copy pathproblem18.c
File metadata and controls
38 lines (29 loc) · 737 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
#include<stdio.h>
#define row 100
#define col 100
int main(){
int arr[101][101];
for(int i = 0; i < row; i++){
for(int j = 0; j<=i; j++){
scanf("%d", &arr[i][j]);
}
}
for(int i = row-1; i >= 90; i--){
for(int j = 0; j<=i; j++){
printf("%d ", arr[i][j]);
}
printf("\n");
}
for(int i = row-2; i>=0; i--){
for(int j = 0; j<=i; j++){
if(arr[i][j]+arr[i+1][j] > arr[i][j] + arr[i+1][j+1])
arr[i][j] += arr[i+1][j];
else
arr[i][j] += arr[i+1][j+1];
//printf("%d ", arr[i][j]);
}
//printf("\n");
}
printf("%d\n", arr[0][0]);
return 0;
}