输入三角形的三条边,求三角形的面积。帮我看看哪里错了,顺便改一下。


#include <iostream>
#include <math.h>
using namespace std;
double s(int a,int b,int c)
{
double p;
p=(a+b+c)/2;
s=sqrt[p*(p-a)*(p-b)*(p-c)];
return 0;
}
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<"面积为"<<s(a,b,c)<<endl;
    return 0;
}

修改如下


#include <iostream>
#include <math.h>
using namespace std;
double s(int a, int b, int c)
{
    double p, s;
    p = (a + b + c) / 2;
    s = sqrt(p * (p - a) * (p - b) * (p - c));
    return s;
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << "面积为" << s(a, b, c) << endl;
    return 0;
}