zoukankan      html  css  js  c++  java
  • 16、输入三角形的三个边,求其面积

    输入三角形的三个边,求其面积

    程序代码:

     
    /*
    	2017年6月30日15:27:22
    	功能:输入三角形的三个边,求其面积。
    */
    # include <stdio.h>
    # include <math.h>
    # include <stdlib.h>
    
    int main(void)
    {
    	 float a, b, c, p, s;
    
    	 printf("请输入三角形的三个边长,以空格分隔:");
     
    	 scanf("%f %f %f", &a, &b, &c);
    
    	 if (a+b>c && b+c>a && a+c>b )				//三角形两边之和没有大于第三边,无法构成三角形
    	 {
    		  p = (a + b + c)/2;
    
    		  s = sqrt (p*(p-a)*(p-b)*(p-c));		//sqrt函数是指的开方运算函数
    
    		  printf("该三角形的面积为:%f
    ", s);
    	 }
     
    	 else 
    		  printf("Error
    ");
    
    	 system("pause");
    
    	 return 0;
    }
    /*
    ----------------
    请输入三角形的三个边长,以空格分隔:5 7 8
    该三角形的面积为:17.320508
    ----------------
    */
    

      

     

     

  • 相关阅读:
    KVCKVO
    音频
    静态库
    百度地图API
    CALayer
    触摸事件
    iOS中打电话、打开网址、发邮件、发短信等
    NSURLSession网络接口
    Quartz2D常见图形的绘制:线条、多边形、圆
    通知中心(NSNotificationCenter)
  • 原文地址:https://www.cnblogs.com/wxt19941024/p/6546448.html
Copyright © 2011-2022 走看看