current position:Home>Why do you report an error? Find a solution

Why do you report an error? Find a solution

2022-02-02 23:23:45 CSDN Q & A

#include<stdio.h>
#include<math.h>
double area(double x,double y,double z);
{
double p=(x+y+z)/2;
return sqrt(p*(p-x)(p-y)(p-z));
}
int main()
{
double a1,a2,a3,a4,a5,a6,a7,s;
printf("input 7 sise lengths in the order a1 to a7:\n");
scanf("%lf%lf%lf%lf%lf%lf%lf",&a1,&a2,&a3,&a4,&a5&,a6,&a7);
s=area(a1,a5,a6)+area(a4,a6,a7)+area(a2,a3,a7);
printf("the area of the pentagon is:%.2f\n",s);
return 0;
}




Refer to the answer 1:

double area(double x,double y,double z);
Delete the semicolon after it
In addition, in the function, you should check whether the length of three sides can form a triangle , otherwise sqrt The parameter of may be a negative number , Something's going to go wrong




Refer to the answer 2:



Refer to the answer 3:

scanf("%lf%lf%lf%lf%lf%lf%lf",&a1,&a2,&a3,&a4,&a5&,a6,&a7);
a6 Ahead , and & It's written backwards




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022323433592.html

Random recommended