分享

274

 木俊 2018-05-06
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);
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多