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编译flag/2得到的是小数?#include<stdio.h> #include<stdlib.h> void calculate(int len,int num) { int e_temp,l_temp,posit,i; int earlist=-1,latest=-1,flag=len/2; for(i=0;i<num;i++) { scanf("%d",&posit); if(posit<=flag) { e_temp=posit; //在左半边,得到最快掉下去的时间 l_temp=len-posit;// 得到最慢掉下去的时间 } else { e_temp=len-posit;//在右半边 l_temp=posit-1; } if(earlist<e_temp) earlist=e_temp; if(latest<l_temp) latest=l_temp; } printf("%d %d\n",earlist,latest); } int main() { int N,len,num; scanf("%d",&N); while(N--) { scanf("%d%d",&len,&num); calculate(len,num); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator