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 |
终于水过了 我的天,竟然是忘了每次循环吧min,max初始化#include <stdio.h> int max(int a,int b) { return a>b?a:b; } int min(int a,int b) { return a<b?a:b; } int a[1000001]; int main() { int N,l,n,i,min1=0,max1=0; scanf("%d",&N); while(N--) { min1=0; max1=0; scanf("%d%d",&l,&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { min1=max(min1,min(a[i],l-a[i])); max1=max(max1,max(a[i],l-a[i])); } printf("%d %d\n",min1,max1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator