欢迎来到天天文库
浏览记录
ID:57686802
大小:13.50 KB
页数:2页
时间:2020-09-01
《C++实现欧几里得距离的计算.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#includeusingnamespacestd;//calculatetheEuclid'sdistant///////////////////////////////////////////////////////////////////////////classDistance{public:Distance(intm,doublearray1[],doublearray2[]);voiddistance(doublea[],doubleb[]);//calculatethedistance
2、voidset(doublearray1[],doublearray2[]);doubleget(){returnResult;}~Distance(){}private:intn;double*a;//declaretwoobjectsdouble*b;doublesquare;doubleResult;//TheresultofEuclid'sdistanst};Distance::Distance(intm,doublearray1[],doublearray2[]){n=m;set(array1,array2);distance(a,b);
3、}voidDistance::set(doublearray1[],doublearray2[]){a=array1;b=array2;}voidDistance::distance(doublea[],doubleb[]){square=0;for(inti=0;i4、unctionintmain(){intn;cout<<"Pleaseinputthedimensionsn:";cin>>n;doublea[n];doubleb[n];cout<<"Inputthe"<>a[i];cout<<"Inputthe"<>b[i];Distancedistance(n,a,b);cout<<"5、Thedistanceis:"<
4、unctionintmain(){intn;cout<<"Pleaseinputthedimensionsn:";cin>>n;doublea[n];doubleb[n];cout<<"Inputthe"<>a[i];cout<<"Inputthe"<>b[i];Distancedistance(n,a,b);cout<<"
5、Thedistanceis:"<
此文档下载收益归作者所有