朱色虫居
Pages
Home
Featured Posts
2006/09/08
476-Points in Figures: Rectangles
/*
"Points in Figures: Rectangles"
Level:3.0
Date:2006/9/7
技巧:
長方形的判斷: x > 左上角的x && x < 右下角的x && y < 左上角的y && y > 右下角的y
*/
#include
struct rectangle{
double upperLeft_X;
double upperLeft_Y;
double lowerRight_X;
double lowerRight_Y;
}rec[10];
main(){
int i;
int no=1;
bool contain = false;
int len = 0;
double x,y;
char temp;
while(scanf("%c",&temp)){
if(temp == 'r'){
scanf("%lf %lf %lf %lf",&rec[len].upperLeft_X,&rec[len].upperLeft_Y,
&rec[len].lowerRight_X,&rec[len].lowerRight_Y);
len++;
}
else if(temp == '*')
break;
}
while(scanf("%lf %lf",&x,&y)){
if(x == 9999.9 && y == 9999.9)
break;
for(i=0;i
rec[i].upperLeft_X && x < rec[i].lowerRight_X && y < rec[i].upperLeft_Y && y > rec[i].lowerRight_Y){
printf("Point %d is contained in figure %d\n",no,i+1);
contain = true;
}
}
if(contain == false)
printf("Point %d is not contained in any figure\n",no);
no++;
contain = false;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment