#include
#include
struct point
{
float x;
float y ;
};
double distant(point &a,point &b)
{
double d,di;
d = (a.x-b.x)*(a.x-b.x)-(a.y-b.y)*(a.y-b.y);
di = sqrt(d);
return di;
}
void main ( )
{
point a,b,c,d;
cout <<"input four point : " <
cout <<"input point first : (" ;
cin >>a.x;
cout << ",";
cin >>a.y;
cout <<")"<
cout <<"input point second : (" ;
cin >>b.x;
cout << ",";
cin >>b.y;
cout <<")"<
cout <<"input point third : (" ;
cin >>c.x;
cout << ",";
cin >>c.y;
cout <<")"<
cout <<"input point forth : (" ;
cin >>d.x;
cout << ",";
cin >>d.y;
cout <<")"<
double AB,BC,CD,DA,AC,BD;
AB = distant(a,b);
BC = distant(b,c);
CD = distant(c,d);
DA = distant(d,a);
AC = distant(a,c);
BD = distant(b,d);
int parallelogram, rectangle, square;
parallelogram = (AB==CD) && (BC==DA) ; //平行四边形
rectangle = parallelogram && (AC==BD) ; //矩形
square = rectangle && (AB==BC); //正方形 quadrangle : 四边形
if ( square)
{
cout << "it is a spuare!"<}else if ( rectangle )
{
cout << " It is a rectangle!"<}else
{
cout << " it is a quadrangle!"<}
}
-------------------------------------------------------------
/* cout <<"input point first : (" ; -
cin >>a.x;
cout << ",";
cin >>a.y;
cout <<")"<*/
----------------------------------------------------------------------------
这样输入麻烦 ,要cin 一次就按一次 enter 不爽 !!
不知有没有爽的法子?
--------------------next---------------------
阅读(1116) | 评论(0) | 转发(0) |