Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么我这样写错的?难道是POJ编译flag/2得到的是小数?

Posted by hacker_w at 2009-08-23 23:37:47 on Problem 1852
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator