谢谢,问题解决了一个,很开心!
但是另外还有解决不出,主要都是关于函数的问题,对这个概念还是有点含糊,我觉得我很的不好。你们可帮忙吗?
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
#include <iostream>
#include <cmath>
using namespace std;
//a)
/*@distance.
*@double distance(double x1, double x2,double y1, double y2)
*/
double distance(double x1,double x2,double y1,double y2)
{
double distance;
distance=sqrt(pow((x2-x1),2)+ pow((y2-y1),2));
return distance;
}
//b)
/*@mid distance.
*@double distance(double x1, double x2,double y1, double y2,double &midX, double &midY);
*/
void midpoint(double x1,double x2,
double y1,double y2,
double *midX, double *midY)
{
*midX=(x2-x1)/2.0;
*midY=(y2-y1)/2.0;
//cout<<(x2-x1)/2.0<<","<< (y2-y1)/2.0;
}
//c)
/*@diameter.
*@double radius(double x1, double y1,
*
double x2, double y2)
*/
void radius(double x1, double y1,
double x2, double y2)
{
//double radius;
double diameter;
double r;
distance(x1,x2,y1,y2);
r=diameter/2.0;
return radius(x1,x2,y1,y2);
}
//d)
/*@circumference(double r)
*@double radius(double x1, double y1,
*
double x2, double y2)
*/
//double circumference(double r);
double circumference(double r){
const double PI=3.14;
double circumference;
circumference=2*PI* r;
//return circumference(r);
return circumference;
}
//e)
/*@circumference.
*@double circumference(double x1, double y1,
double x2, double y2)
*/
double circumference(double x1, double y1, double x2, double y2)
{
const double PI=3.14;
distance(x1,x2,y1,y2);
return circumference(x1,x2,y1,y2);
}
int main()
{
double x1,x2,y1,y2;
cout<<"enter x1,x2,y1,y2:"<<endl;
cin>> x1>>x2>>y1>>y2;
distance(x1,x2,y1,y2);
cout<<" The distance between them is:"<< distance <<endl;
cout<<"midpoint is:"<<x2-x1<<",y2-y1"<endl;
cout<<"the circle's radius is:"<<
return 0;
}