ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

What is "Compilation Error!!"?
Posted by sonteenzz 5 May 2003 23:54
describe about this error plz
Oh men! There is a bug in da program which makes it impossible to compile(-)
Posted by uuuuuuu 6 May 2003 00:18
Re: What is "Compilation Error!!"?
Posted by sonteenzz 6 May 2003 01:40
Where is a bug?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int lap = 0;
int min(int x,int y){
    if (x>=y)
        return y;
    else
        return x;
}
int max(int x,int y){
    if (x>=y)
        return x;
    else
        return y;
}
int mint(int i,int k,int n,int dis[]){
    if (i+k < n){
        if (dis[i] < 0)
            mint(i+1,1,n,dis);
        else if ((dis[i+k] >= 0))
            if (dis[i]<=dis[i+k])
                mint(i,k+1,n,dis);
            else
                mint(i+k,1,n,dis);
        else
            mint(i,k+1,n,dis);
    }else if(lap<n){
        dis[i] = -1;
        printf("%d",i+1);
        lap++;
        if (lap<n)
            printf(" ");
        mint(0,1,n,dis);
    }
    return 0;
}
int disPoint(int x1,int y1,int x2,int y2){
    return (int) sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
}
int check(int px,int py,int x1,int y1,int x2,int y2){
    if ((x1<=px)&&(px<=x2)&&(y1<=py)&&(py<=y2)){
        return 0;
    }else if((x1<=px)&&(px<=x2)){
        if (py>y2)
            return py-y2;
        else
            return y1-py;
    }else if((y1<=py)&&(py<=y2)){
        if (px>x2)
            return px-x2;
        else
            return x1-px;
    }else {
        return min(disPoint(px,py,x1,y1),min(disPoint
(px,py,x1,y2),min(disPoint(px,py,x2,y1),disPoint(px,py,x2,y2))));
    }
}
int main(void){
    char nSqr;
    int px,py,*dis;
    struct Sqr{
        int x1,x2,y1,y2;
    } *s;
    scanf("%d",&nSqr);
    s = (Sqr*) malloc(sizeof(Sqr)*nSqr);
    dis = (int*) malloc(sizeof(int)*nSqr);
    for (int i = 0;i<nSqr;i++){
        scanf("%d %d %d %d",&s[i].x1,&s[i].y1,&s
[i].x2,&s[i].y2);
    }
    scanf("%d %d",&px,&py);
    for (i = 0;i<nSqr;i++){
        dis[i] = check(px,py,min(s[i].x1,s[i].x2),min(s
[i].y1,s[i].y2),max(s[i].x1,s[i].x2),max(s[i].y1,s[i].y2));
    }
    mint(0,1,nSqr,dis);
    free(s);
    free(dis);
    return 0;
}