cs11_c++_lab1

lab1.cppios

 1 #include "Point.hh"
 2 #include <iostream>
 3 #include <cmath>
 4 
 5 using namespace std;
 6 
 7 double computeArea(Point &a, Point &b, Point &c)
 8 {
 9     double x=a.distanceTo(b);
10     double y=b.distanceTo(c);
11     double z=c.distanceTo(a);
12     
13     double len=(x+y+z)/2;
14 
15     double size=sqrt(len*(len-x)*(len-y)*(len-z));
16 
17     return size;
18 }
19 int main()
20 {
21 
22 Point p1;
23 Point p2(-2,0);
24 Point p3(0,2);
25 
26 cout<<computeArea(p1,p2,p3)<<endl;
27 
28 return 0;
29 
30 }
View Code
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息