1127: Find Circumference, Area, Spherical Area, Spherical Volume, Cylinder Volume

topic description

Assuming that the radius of the circle is r, and the height of the cylinder is h, find the circumference C1, the area of ​​the circle Sa, the surface area of ​​the sphere Sb, the volume of the sphere Va, and the volume of the cylinder Vb.

Input data, output calculation results, and require text descriptions when outputting, and take two digits after the decimal point. Please program. PI=3.14

circumference:

Circle area:

Ball surface area:

Ball volume:

Cylindrical volume:

enter

two floating point numbers, r and h

output

Circumference C1, circle area Sa, sphere surface area Sb, sphere volume Va, cylinder volume Vb. Round to two decimal places and wrap after each result.

sample input

1.5 3

sample output

C1=9.42

Sa=7.07

Sb=28.26

Va=14.13

Vb=21.20

light update

Routine for taking 5 digits after the decimal point:

C language routine:

#include <stdio.h>
int main()
{
	float a = 1.234567;
	printf("%.5f", a);
	return 0;
}

C++ language routine:

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	float a = 1.234567;
	cout << setprecision(5) << fixed << a << endl;
	return 0;
}

Whether you understand it or not, just go straight to the code (lazy...)

Recently, I have been studying crazy, and I am too lazy to update

#include <iostream>  
#include <iomanip>
using namespace std;
int main()
{
    float r,h,PI;
    PI=3.14;
    cin>>r>>h;
    cout<<"C1=";
    cout<<fixed<<setprecision(2)<<2*PI*r<<endl;
    cout<<"Sa=";
    cout<<fixed<<setprecision(2)<<r*PI*r<<endl;
    cout<<"Sb=";
    cout<<fixed<<setprecision(2)<<4*PI*r*r<<endl;
    cout<<"Va=";
    cout<<fixed<<setprecision(2)<<r*PI*r*r*4.0/3<<endl;
    cout<<"Vb=";
    cout<<fixed<<setprecision(2)<<r*PI*r*h;
    return 0;
} 

Remember to follow + like it (the above code is from AC !!!)

Guess you like

Origin blog.csdn.net/qiuweichen1215/article/details/129369947