【C语言设计】习题3.7

avatar

azurekiln

#include <stdio.h>
#include <math.h>
#define pai 3.14159

int main() {
    //圆半径
    float r = 1.5;
    //圆柱高
    int h = 3;
    //声明变量 
    float C,V1,S1,V2,S2;

    //圆周长计算 (C)
    C = 2 * pai * r;
    //圆面积计算 (S1)
    S1 = pai * pow(r,2);
    //圆球表面积计算 (S2)
    S2 = 4 * pai * pow(r,2);
    //圆球体积计算 (V1)
    V1 = 4/3 * pai * pow(r,3);
    //圆柱体体积计算 (V2)
    V2 = S1 * h;

    printf("圆周长C:%.2f",C); 
    printf("\n圆面积S1:%.2f",S1);
    printf("\n圆球表面积S2:%.2f",S2); 
    printf("\n圆球体积V1:%.2f",V1);
    printf("\n圆柱体体积V2:%.2f",V2); 

    return 0;
}

扫描二维码,在手机上阅读
收藏
请先 登录 再评论
powered by emlog pro
服务器供应商 景云数据

友情链接
白衣Ink


sitemap