码迷,mamicode.com
首页 > 其他好文 > 详细

三角形的面积

时间:2018-08-02 11:16:27      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:argv   sys   his   nbsp   get   you   clu   div   ios   

 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 }

 

三角形的面积

标签:argv   sys   his   nbsp   get   you   clu   div   ios   

原文地址:https://www.cnblogs.com/borter/p/9405594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!