三角形的面积

 1 #include <iostream>
 2 #include <cmath>
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 int main(int argc, char** argv) {
 6     double triangle(double,double,double);
 7     double a,b,c;
 8     cin >>a>>b>>c;
 9     while(a>0&&b>0&&c>0)
10     {
11         cout<<triangle(a,b,c)<<endl;
12         cin>>a>>b>>c;
13     }
14     return 0;
15 }
16 
17 double triangle(double a,double b,double c)
18 {
19     double area;
20     double s=(a+b+c)/2;
21     area=sqrt(s*(s-a)*(s-b)*(s-c));
22     return area;
23 }

 

posted @ 2018-08-02 10:25  borter  阅读(253)  评论(0编辑  收藏  举报