Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341853
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:03:54


#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) |
给主人留下些什么吧!~~