解题思路:
注意事项:
参考代码:
#include<stdio.h> int main() { int m, n, a[41][41], i, j, k, l; while (scanf("%d%d", &m, &n) != EOF) { for (i = 0; i < m; ++i) { for (j = 0; j < n; ++j) { scanf("%d", &a[i][j]); } } int sum = a[i - 1][j - 1]; int row = 0, line = 0; while (row != m - 1 || line != n - 1) { int max = 0; sum += a[row][line]; a[row][line] = 0; int t1 = row, t2 = line; for (k = row - 1; k <= row + 1; k++) { for (l = line - 1; l <= line + 1; l++) { if (row != k&&line != l) continue; if (k < 0 || l < 0 || k == m || l == n || (k == row&&l == line)) continue; if (a[k][l] > max) { t1 = k; t2 = l; max = a[k][l]; } } } row = t1; line = t2; } printf("%d\n", sum); } return 0; }
0.0分
0 人评分
大小写转换 (C语言代码)浏览:904 |
【偶数求和】 (C语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:699 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:524 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:612 |
整除问题 (C语言代码)浏览:594 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:653 |
简单的a+b (C语言代码)浏览:497 |
汽水瓶 (C语言代码)浏览:579 |