C语言的题目,求解答

img

#include <stdio.h>
#include <math.h>
int main()
{
    double a,b,c,s,area;
    scanf("%lf %lf %lf",&a,&b,&c);
    if( a+b > c && b+c > a && a+c>b)
    {
        s = (a+b+c)/2;
        area = sqrt(s*(s-a)*(s-b)*(s-c));
        printf("%.2lf",area);
    }else
        printf("不能组成三角形");
    
    return 0;
}

sqrt的原型


#include <stdio.h>
#ifdef CONFIG_64BIT
#define BITS_PER_LONG 64
#else
#define BITS_PER_LONG 32
#endif
/**
 * int_sqrt - rough approximation to sqrt
 * @x: integer of which to calculate the sqrt
 *
 * A very rough approximation to the sqrt() function.
 */
unsigned long int_sqrt(unsigned long x)
{
    unsigned long op, res, one;
    op = x;
    res = 0;
    one = 1UL << (BITS_PER_LONG - 2);
    while (one > op)
        one >>= 2;

    while (one != 0) {
        if (op >= res + one) {
            op = op - (res + one);
            res = res +  2 * one;
        }
        res /= 2;
        one /= 4;
    }
    return res;
}