#include<iostream.h> #include<math.h> class a5 { public: float point(int a1,int a2,int b1,int b2) { return (float)sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2)); } float point(float a1,float a2,float b1,float b2) { return (float)sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2)); } }; void main() { float a,b,c,d; int j; a5 dis; for(int i=0;;i++) { cout<<"请输入一点的横纵坐标"<<endl; 求平面上两点之间的距离 cin>>a>>b; cout<<"请输入另一点的横纵坐标"<<endl; cin>>c>>d; if(a==(int)a) cout<<"平面上这两点的距离为:"<<dis.point((int) a,(int) b,(int) c,(int) d)<<endl; else cout<<"平面上这两点的距离为:"<<dis.point(a,b,c,d)<<endl; cout<<"如果想继续输入请按1,否则按0"<<endl; cin>>j; if(j) continue; else break; } }