页码
程序
23 计算半径为 6.5 厘米的圆球的体积
28 求两个相邻边的长度分别为 3.5 和 4.72 米,两边夹角为 37 度的三角形的面积
29 求三边的长度分别是3、5、7厘米的三角形的面积
返回 总目录

例:计算半径为 6.5 厘米的圆球的体积

#include <stdio.h>

main() {
     printf("V = %fcm^3\n",
            (3.1416 * 6.5 * 6.5 * 6.5) * 4.0 / 3.0);
}

例:求两个相邻边的长度分别为 3.5 和 4.72 米,两边夹角为 37 度的三角形的面积

#include <stdio.h>
#include <math.h>

main () {
    printf("Area of the triangle: %fm^2\n",
           3.5 * 4.72 * sin(37.0 / 180 * 3.1416) / 2);
}

例:求三边的长度分别是3、5、7厘米的三角形的面积

#include <stdio.h>
#include <math.h>

main () {
    printf("%f\n", sqrt((3+5+7)/2.0 * ((3+5+7)/2.0 - 3) *
                   ((3+5+7)/2.0 - 5) * ((3+5+7)/2.0 - 7)));
}