Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- struct vec2{
- double x,y;
- vec2(){
- x=0;
- y=0;
- }
- vec2(double x_, double y_){
- x = x_;
- y = y_;
- }
- double lengh(){
- return sqrt(x*x+y*y);
- }
- void print(){
- cout<<x<<' '<<y<<endl;
- }
- void set_polar(double ph, double r){
- y = r*sin(ph);
- x = r*cos(ph);
- }
- };
- int main()
- {
- vec2 a(2,5),b(1,3);
- /*cout<<a.lengh()<<endl;
- cout<<b.lengh()<<endl;*/
- a.set_polar(0.785,3);
- b.set_polar(0.785,1);
- a.print();
- b.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement