zoukankan      html  css  js  c++  java
  • 计算几何DotVector

    This article is made by Jason-Cow.
    Welcome to reprint.
    But please post the article's address.

    看了书,然后码

     1 struct D{
     2   db x,y;
     3   D(db x=0.0,db y=0.0):x(x),y(y){}
     4 };
     5 typedef D V;
     6 bl op<(D A,D B){return A.x<B.x||(A.x==B.x&&A.y<B.y);}
     7 V op+(V A,V B){return V(A.x+B.x,A.y+B.y);}
     8 V op-(V A,V B){return V(A.x-B.x,A.y-B.y);}
     9 V op*(V A,db N){return V(A.x*N,A.y*N);}
    10 V op/(V A,db N){return V(A.x/N,A.y/N);}
    int main(){
       A[1]=V(1,2);
       cout<<A[1].x<<" "<<A[1].y<<endl;
       cout<<A[2].x<<" "<<A[2].y<<endl;
       A[2].y+=1.0,cout<<"add"<<endl;
       A[3]=A[1]+A[2];
       cout<<A[3].x<<" "<<A[3].y<<endl<<endl;
       sort(A+1,A+3+1);
       for(int i=1;i<=3;i++)cout<<A[i].x<<" "<<A[i].y<<endl;
       return 0;
    }
    1 2
    0 0
    add
    1 3
    
    0 1
    1 2
    1 3
    ~~Jason_liu O(∩_∩)O
  • 相关阅读:
    开发day7
    开发day6
    开发day5
    开发day4
    开发day3
    开发day2
    开发day1
    假期学习2/8
    什么是栈帧
    JDK、JRE和JVM到底是什么
  • 原文地址:https://www.cnblogs.com/JasonCow/p/6583012.html
Copyright © 2011-2022 走看看