JD_Source Code for problem 1259
2008-06-07 11:45
429 查看
题目链接:http://acm.jlu.edu.cn/joj/showproblem.php?pid=1259
#include <stdio.h>
#include <math.h>
struct Point
{
double x;
double y;
};
struct Figure
{
char type;
Point p1;
Point p2;
double r;
};
Figure fig[11];
Point pt[100];
bool In(const Point& p,const Figure& f)
{
if(f.type == 'r')
{
if(p.x > f.p1.x && p.x < f.p2.x && p.y > f.p2.y && p.y < f.p1.y)
return true;
return false;
}
else
{
if(sqrt((p.x -f.p1.x) * (p.x -f.p1.x) + (p.y - f.p1.y) * (p.y - f.p1.y)) < f.r)
return true;
return false;
}
}
int main(int argc, char* argv[])
{
int f_count,p_count;
f_count = 0;
while(true)
{
if(scanf("%c",&fig[f_count].type) == EOF)
return 0;
else if(fig[f_count].type == '*')
break;
else if(fig[f_count].type == 'r')
scanf("%lf%lf%lf%lf",&fig[f_count].p1.x,&fig[f_count].p1.y,
&fig[f_count].p2.x,&fig[f_count].p2.y);
else
scanf("%lf%lf%lf",&fig[f_count].p1.x,&fig[f_count].p1.y,&fig[f_count].r);
getchar();
f_count++;
}
p_count = 0;
while(true)
{
if(scanf("%lf%lf",&pt[p_count].x,&pt[p_count].y) == EOF)
return 0;
else if(fabs(pt[p_count].x - 9999.9) < 1e-6 && fabs(pt[p_count].y - 9999.9) < 1e-6)
break;
p_count++;
}
int i,j;
bool in;
for(i = 0;i < p_count;i++)
{
in = false;
for(j = 0;j < f_count;j++)
if(In(pt[i],fig[j]))
{
printf("Point %d is contained in figure %d/n",i + 1,j + 1);
in = true;
}
if(!in)
printf("Point %d is not contained in any figure/n",i + 1);
}
return 0;
}
#include <stdio.h>
#include <math.h>
struct Point
{
double x;
double y;
};
struct Figure
{
char type;
Point p1;
Point p2;
double r;
};
Figure fig[11];
Point pt[100];
bool In(const Point& p,const Figure& f)
{
if(f.type == 'r')
{
if(p.x > f.p1.x && p.x < f.p2.x && p.y > f.p2.y && p.y < f.p1.y)
return true;
return false;
}
else
{
if(sqrt((p.x -f.p1.x) * (p.x -f.p1.x) + (p.y - f.p1.y) * (p.y - f.p1.y)) < f.r)
return true;
return false;
}
}
int main(int argc, char* argv[])
{
int f_count,p_count;
f_count = 0;
while(true)
{
if(scanf("%c",&fig[f_count].type) == EOF)
return 0;
else if(fig[f_count].type == '*')
break;
else if(fig[f_count].type == 'r')
scanf("%lf%lf%lf%lf",&fig[f_count].p1.x,&fig[f_count].p1.y,
&fig[f_count].p2.x,&fig[f_count].p2.y);
else
scanf("%lf%lf%lf",&fig[f_count].p1.x,&fig[f_count].p1.y,&fig[f_count].r);
getchar();
f_count++;
}
p_count = 0;
while(true)
{
if(scanf("%lf%lf",&pt[p_count].x,&pt[p_count].y) == EOF)
return 0;
else if(fabs(pt[p_count].x - 9999.9) < 1e-6 && fabs(pt[p_count].y - 9999.9) < 1e-6)
break;
p_count++;
}
int i,j;
bool in;
for(i = 0;i < p_count;i++)
{
in = false;
for(j = 0;j < f_count;j++)
if(In(pt[i],fig[j]))
{
printf("Point %d is contained in figure %d/n",i + 1,j + 1);
in = true;
}
if(!in)
printf("Point %d is not contained in any figure/n",i + 1);
}
return 0;
}
相关文章推荐
- JD_Source Code for problem 1581
- JD_Source Code for problem 1379
- ZD_source code for problem 2971
- BD_source code for problem 1555
- Source Code for the Built-in ASP.NET 2.0 Providers Now Available for Download !
- there is no source code available for the current location的解决方法
- Android: Simplified source code for parsing and working with XML data and web services in Android
- 算法导论problem 24-5 Gabow's algorithm for single source shortest path
- there is no source code available for the current location的解决方法
- Source code for Bayesian based CS and blind debluring
- How to get Mokee Android N source code for Oneplus One Bacon device?
- there is no source code available for the current location 解决方案
- Windows 95 VxD C Source Code for VANYDEVD
- There is no source code available for the current location.
- 12 Source Code Profilers for C & C++
- Releasing the Source Code for the .NET Framework Libraries!
- Configure Javadoc and Source Code for JRE in Eclipse JDT
- There is No Source Code Available for the Current Location
- Source Code for the Built-in ASP.NET 2.0 Providers Now Available for Download !
- [Delphi]ExpressQuantumGrid_Suite_v5.0_Full_Source_Code_for_Delphi_7 控件包的修正及安装方法