圆的计算

/*

* Copyright (c) 2012, 烟台大学计算机学院

* All rights reserved.

* 作 者:赵晓晨

* 完成日期:2012 年 10月22 日

* 版 本 号:v1.0 *

* 输入描述:

* 问题描述:

* 程序输出

* 问题分析:

* 算法设计:

  1. #include <iostream>     
  2. #include <Cmath>    
  3. #define PI 3.1415926  
  4. using namespace std;     
  5. int main()     
  6. {     
  7.     double r,h,s1,s2,s3,s4,l,v1,v2,v3;     
  8.     cout<<"请输入半径r:";     
  9.     cin>>r;     
  10.     cout<<"请输入高h:";     
  11.     cin>>h;     
  12.     s1=PI*r*r;     
  13.     s2=4*PI*r*r;     
  14.     s3=2*PI*r*r+2*PI*r*h;     
  15.     s4=PI*r*r+PI*r*sqrt(h*h+r*r);     
  16.     l=2*PI*r;     
  17.     v1=4*PI*r*r*r/3;     
  18.     v2=PI*r*r*h;     
  19.     v3=PI*r*r*h/3;    
  20.     cout<<"以 "<<r<<" 为半径,"<<endl;   
  21.     cout<<"圆的面积="<<s1<<endl;     
  22.     cout<<"圆的周长="<<l<<endl;        
  23.     cout<<"球的体积="<<v1<<endl;     
  24.     cout<<"球的表面积="<<s2<<endl<<endl;   
  25.     cout<<"以 "<<r<<" 为半径,"<<h<<" 为高,"<<endl;   
  26.     cout<<"圆柱的体积="<<v2<<endl;     
  27.     cout<<"圆柱的表面积="<<s3<<endl;     
  28.     cout<<"圆锥的体积="<<v3<<endl;     
  29.     cout<<"圆锥的表面积="<<s4<<endl;     
  30.     return 0;     
#include <iostream>    
#include <Cmath>   
#define PI 3.1415926 
using namespace std;    
int main()    
{    
    double r,h,s1,s2,s3,s4,l,v1,v2,v3;    
    cout<<"请输入半径r:";    
    cin>>r;    
    cout<<"请输入高h:";    
    cin>>h;    
    s1=PI*r*r;    
    s2=4*PI*r*r;    
    s3=2*PI*r*r+2*PI*r*h;    
    s4=PI*r*r+PI*r*sqrt(h*h+r*r);    
    l=2*PI*r;    
    v1=4*PI*r*r*r/3;    
    v2=PI*r*r*h;    
    v3=PI*r*r*h/3;   
    cout<<"以 "<<r<<" 为半径,"<<endl;  
    cout<<"圆的面积="<<s1<<endl;    
    cout<<"圆的周长="<<l<<endl;       
    cout<<"球的体积="<<v1<<endl;    
    cout<<"球的表面积="<<s2<<endl<<endl;  
    cout<<"以 "<<r<<" 为半径,"<<h<<" 为高,"<<endl;  
    cout<<"圆柱的体积="<<v2<<endl;    
    cout<<"圆柱的表面积="<<s3<<endl;    
    cout<<"圆锥的体积="<<v3<<endl;    
    cout<<"圆锥的表面积="<<s4<<endl;    
    return 0;    
}


运行结果:
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值