java 編寫程序求圓柱體的體積和圓的周長?
編寫程序求圓柱體的體積和圓的周長?內(nèi)容如下:#include<stdio。H>void main(){float R,C,Sprintf(“please input the radius of
編寫程序求圓柱體的體積和圓的周長?
內(nèi)容如下:
#include<stdio。H>
void main()
{
float R,C,S
printf(“please input the radius of the circle:”)
scanf(%f“,&r)/*用于輸入浮點(diǎn)數(shù)據(jù)并將其存儲在地址中&R*/
C=2*3.1415926*R/*用于計(jì)算周長,并將其賦給c*/
s=3.1415926*r*r/*以計(jì)算面積*/
v=4/3*pi*r*r*r/*用于計(jì)算體積*/
printf(“周長c=%8.4f;\n面積s=%8.4f;\n體積v=%8.4f”,c,s,v)/*周長、面積、體積為8個(gè)字符寬,小數(shù)點(diǎn)后4位*/
擴(kuò)展數(shù)據(jù):
圓周長公式:C=2πR
圓面積公式:S=πR^2
球體積公式:v=3/4*πR^3