1 5 5 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
25
源码如下:
#include<stdio.h> int N,HIGH,WIDTH,Max=0; int a[101][101]; void skiing(int m,int n,int t) { if (m-1 >=0){ if (a[m-1][n] < a[m][n]) skiing(m-1,n,t+1);} if (m+1 < HIGH){ if (a[m+1][n] < a[m][n]) skiing(m+1,n,t+1);} if (n-1 >= 0){ if (a[m][n-1] < a[m][n]) skiing(m,n-1,t+1);} if (n+1 < WIDTH){ if (a[m][n+1] < a[m][n]) skiing(m,n+1,t+1);} if (t > Max) Max = t; } int main() { int i,j; scanf("%d",&N); while(N--) { Max = 0; scanf("%d%d",&HIGH,&WIDTH); for (i=0; i < HIGH;i++) for (j=0; j < WIDTH; j++) scanf("%d",&a[i][j]); for (i=0; i < HIGH;i++) for (j=0; j < WIDTH; j++) skiing(i,j,1); printf("%d\n",Max); } return 0; }
原文地址:http://blog.csdn.net/xianyun2009/article/details/39369427