ppoint.cpp
#include"ppoint.h"
#include"iostream"
using namespace std;
int main()
{
ppoint point;
for (double x,y; cout << "enter x and y: \n" &&cin >> x >> y && x > 0;)
{
point.set(x, y);
cout << "angle=" << point.angle() << ", radius=" << point.radius() << endl;
cout << "x.offset" << point.xoffset() << ", y.offset" << point.yoffset() << endl;
}
}
ppoint.h
#pragma once
#ifndef HEADER_PPOINT
#define HEADER_PPOINT
class ppoint
{
double x, y;
public:
void set(double ix,double iy);
double xoffset();
double yoffset();
double angle();
double radius();
};
#endif
ppoint.cpp
#include"ppoint.h"
#include"iostream"
using namespace std;
void ppoint::set(double ix, double iy)
{
x = ix;
y = iy;
}
double ppoint::xoffset()
{
return x;
}
double ppoint::yoffset()
{
return y;
}
double ppoint::angle()
{
return (180 / 3.14159)*atan2(y, x);
}
double ppoint::radius()
{
return sqrt(x*x + y * y);
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。