1、C
/C++
Mathematics calculation ⭐️
1. Before using mathematical operations, you need to introducemath.h
#inclue<math.h>
2. Some mathematical operations
3. Examples
Corresponding code
#include <stdio.h>
#include <math.h> // 引入数学运算
int main()
{
double a, b, c, s, area; // 自定义5个double型变量
printf("请输入三角形的三边长,示例: 1,2,3 \n"); // 提示信息:提示用户输入
scanf("%lf,%lf,%lf", &a, &b, &c); // 用户输入(scanf里,double型对应%lf)
s = (a + b + c) / 2; // 获取到s的值
area = sqrt(s * (s - a) * (s - b) * (s - c)); // 利用题干公式,求出三角形的面积
printf("三角形的面积为%f\n", area); // 输出三角形的面积为?(printf里,double型对应%f; \n是换行符; \t是空格符)
return 0;
}
2.error
-The parentheses before the expression that is obviously called must have a (pointer) function type ⭐️
1, bug
as below:
2. Analyze the reasons
You need to add a sign between multiplications
*
, otherwise the above error will be reported~