c ++ (review) reports on machine experiment 2

First, the problem and the code

/* 
* 文件名称:计算三角形面积.cpp
* 作    者:  宋健
* 完成日期: 2016年 3  月 2 日 
* 版 本 号:v1.0 
* 对任务及求解方法的描述部分:
* 输入描述: 3 4 5
* 问题描述: 无
* 程序输出: 6.00
* 问题分析: 逐次计算
* 算法设计: 已知三边,利用海伦公式求解
*/  
#include <stdio.h>
#include <math.h>
void main()
{
	int a,b,c;
	double S,q;
	scanf("%d%d%d",&a,&b,&c);
	q=(a+b+c)/2;
	S=sqrt(q*(q-a)*(q-b)*(q-c));
	printf("三角形面积S=%.2f\n",S);
}


Second, the results:



Third, the feelings and experiences:

  Relatively easy to accomplish.


Fourth, knowledge summary:

    Use mathematical functions need to add #include <math.h>;

 

         


Published 13 original articles · won praise 0 · Views 2620

Guess you like

Origin blog.csdn.net/Heiraten/article/details/50780028