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 |
第一次来POJ,《挑战》上找的题,竟然败在了初始化MIN和MAX上#include<stdio.h> int _max(int a,int b) { if(a>b)return a; else return b; } int _min(int a,int b) {if(a<b)return a; else return b; } int main() { int t,i,j,L,n,x,max=0,min=0; scanf("%d",&t); for(j=1;j<=t;j++) { max=0;min=0; scanf("%d %d",&L,&n); for(i=0;i<n;i++) { scanf("%d",&x); max=_max(max,_max(x,L-x)); min=_max(min,_min(x,L-x)); } printf("%d %d\n",min,max); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator