Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不知道错哪了(附源程序)#include<stdio.h> main() {int n,b,b1,b2,j,l,m; long k,i; int a[5][5],min[5][5],max[5][5]; scanf("%d%d%ld",&n,&b,&k); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); for(i=0;i<n;i++) for(j=0;j<n;j++) {max[i][j]=a[i][j]; if(i>0&&j>0&&max[i-1][j-1]<max[i][j]) {for(m=i+1-b>0?i+1-b:0;m<=i;m++) for(l=j+1-b>0?j+1-b:0;l<=j;l++) if(max[i][j]>max[m][l])max[m][l]=max[i][j];} else {if(i>0&&max[i-1][j]<max[i][j]) for(m=i-1;m>=0&&m>i-b;m--) if(max[i][j]>max[m][j])max[m][j]=max[i][j]; else break; if(j>0&&max[i][j-1]<max[i][j]) for(m=j-1;m>=0&&m>j-b;m--) if(max[i][j]>max[i][m])max[i][m]=max[i][j]; else break; } } for(i=0;i<n;i++) for(j=0;j<n;j++) {min[i][j]=a[i][j]; if(i>0&&j>0&&min[i-1][j-1]>min[i][j]) {for(m=i+1-b>0?i+1-b:0;m<=i;m++) for(l=j+1-b>0?j+1-b:0;l<=j;l++) if(min[i][j]<min[m][l])min[m][l]=min[i][j];} else {if(i>0&&min[i-1][j]>min[i][j]) for(m=i-1;m>=0&&m>i-b;m--) if(min[i][j]<min[m][j])min[m][j]=min[i][j]; else break; if(j>0&&min[i][j-1]>min[i][j]) for(m=j-1;m>=0&&m>j-b;m--) if(min[i][j]<min[i][m])min[i][m]=min[i][j]; else break; } } for(i=0;i<k;i++) {scanf("%d%d",&b1,&b2); printf("%d\n",max[b1-1][b2-1]-min[b1-1][b2-1]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator