ZZ.2点间距离~123

Jun 1, 2007 23:00

我终于把这个困扰我几千年的题目做出来~~
突然感觉原来好简单的题..天..我智商真低`.还想了那么久..


//使用重载函数length分别求出:
//1.int型数的2点间的距离..
//2.float型数2点间的距离...
//参数类型不同...


#include<iostream.h>
#include<math.h>

float length(int x1,int y1,int x2,int y2)
{
 return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
float length(float x1,float y1,float x2,float y2)
{
 return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

void main()
{

   int x1=3,x2=3,y1=6,y2=3;
 float w=4.5,u=3.1,v=4.2,n=3.7,t1,t2;
 t1=length(x1,y1,x2,y2);
 t2=length(w,u,v,n);
 cout<<t1<<endl;
 cout<<t2<<endl;
}

Category: c++的某些作业阅读(1249) 评论(0)

昵称   密码   游客无需密码
网址   电邮   [注册]

 

最新日志

最新评论

最新留言

随机日志

养家糊口

酷站链接

魔域私服
传奇私服
魔域私服网

其他

登入
注册
申请链接
RSS: 日志 | 评论
编码:UTF-8
XHTML 1.0