rwkj 1327 圓柱體體積

來源:互聯網
上載者:User

標籤:java   使用   os   io   amp   時間   ad   ef   

C語言實驗一(順序):題目2、圓柱體體積
時間限制(普通/Java):1000MS/3000MS 運行記憶體限制:65536KByte
總提交:494 測試通過:196

描述


請編寫一個程式實現以下要求:

1、輸入圓柱體的半徑(radius)和高(high);

2、定義PI為3.14159;

3、求出圓柱體的體積。


輸入


輸入兩個實數,第一個是圓柱體的半徑,第二個是圓柱體的高。


輸出


輸出有三行:

第一行是圓柱體的半徑;

第二行是圓柱體的高;

第三行圓柱體的體積。

每一個輸出的結果保留到小數點後3位。


範例輸入

3.8 5
3 4

範例輸出

radius:3.800
high:5.000
The volume is:226.823
radius:3.000
high:4.000
The volume is:113.097

提示


使用double類型

 

 


#include <stdio.h>
int main()
{ double r,h;
while (scanf("%lf%lf",&r,&h)==2)
{
printf("radius:%.3f\n",r);
printf("high:%.3f\n",h);
printf("The volume is:%.3f\n",3.14159*r*r*h);
}
}

 


#include <stdio.h>

int main()
{ double r,h,v;
while ( scanf("%lf%lf",&r,&h) !=EOF )
{ v=3.14159*r*r*h;
printf("radius:%.3lf\n",r);
printf("high:%.3lf\n",h);
printf("The volume is:%.3lf\n",v);
}

}

 

 

 

 

#include<iostream>
#define PI 3.14159
#include<iomanip>
using namespace std;
int main()
{
double radius,high;
while(cin>>radius>>high)
{
cout<<fixed<<setprecision(3)<<"radius:"<<radius<<endl<<"high:"<<high<<endl<<"The volume is:"<<PI*radius*radius*high<<endl;
}return 0;
}

 

 

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{ double r,h,v;
while (cin>>r>>h)
{ cout<<fixed<<setprecision(3)<<"radius:"<<r<<endl;
cout<<fixed<<setprecision(3)<<"high:"<<r<<endl;
cout<<fixed<<setprecision(3)<<"The volume is:"
<<3.14159*r*r*h<<endl;
}

return 0;
}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.