제6 주 프로젝트 1
/*
* Copyright (c)2013,
* All rightsreserved.
* : array.cpp
* :
* :2014 4 1
* : v1.0
* :
*/
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
class CPoint
{
private:
double x; //
double y; //
public:
CPoint(double xx=0,double yy=0);
double Distance1(CPoint p) const; // ( , p)
double Distance0() const; //
CPoint SymmetricAxis(char style) const;//style 'x','y' 'o' x , y ,
void input(); // x,y
void output(); // (x,y)
};
CPoint::CPoint(double xx,double yy)
{
x=xx;
y=yy;
}
double CPoint::Distance1(CPoint p) const // ( , p)
{
return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
}
double CPoint::Distance0() const //
{
return sqrt(x*x+y*y);
}
CPoint CPoint::SymmetricAxis(char style) const//style 'x','y' 'o' x , y ,
{
CPoint p;
switch(style)
{
case 'x':
p.x=x;
p.y=-y;
break;
case 'y':
p.x=-x;
p.y=y;
break;
case 'o':
p.x=-x;
p.y=-y;
break;
}
return p;
}
void CPoint::input() // x,y
{
cout<<" (x) (y) :"<<endl;
cin>>x>>y;
}
void CPoint::output() // (x,y)
{
cout<<" :("<<x<<","<<y<<")";
}
int main()
{
CPoint a,b,c;
int chose;
b.input();
a.input();
a.output();
while(1)
{
cout<<" :"<<endl;
cout<<"1. 2. "<<endl;
cout<<"3. x 4. y "<<endl;
cout<<"5. "<<endl;
cin>>chose;
switch(chose)
{
case 1:
cout<<" :"<<a.Distance1(b)<<endl;
break;
case 2:
cout<<" :"<<a.Distance0()<<endl;
break;
case 3:
c=a.SymmetricAxis('x');
c.output();
break;
case 4:
c=a.SymmetricAxis('y');
c.output();
break;
case 5:
c=a.SymmetricAxis('o');
c.output();
break;
default:
cout<<" , "<<endl;
cin>>chose;
}
}
return 0;
}
두 점 사이 의 거 리 를 만 들 때 는 정말 많은 시간 이 걸 렸 고, 다른 사람의 조언 으로 마침내 완성 되 었 다.쉽 지 않 은 데...뭔 가 돌아 가 는 것 같 아.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.