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

终于水过了 我的天,竟然是忘了每次循环吧min,max初始化

Posted by 1207125034 at 2014-10-27 12:18:48 on Problem 1852
#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:
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