Title Description
according to the RADIUS R to find the area of a circle , If you do not specify the number of decimal digits , The output is left two decimal places by default.
Some of the code is given below, just submit the missing code.
#include <iostream>
#include <iomanip>
using namespace Std;
const double pi=3.14159;
/*
Supplemental Missing Code
*/
int main ()
{
Double R;
int precision;
cin>>r>>precision;
Showarea (R);
Showarea (r,precision);
return 0;
}
Input
Input Radius R and the number of decimal digits reserved
Output
The area of the first line of the output circle (by default decimal place)
The area of the output circle in the second row (by the specified number of decimal digits)
Sample input
4 1
Sample output
50.27
50.3
The code is as follows:
#include <iostream> #include <iomanip>using namespace Std;const double pi=3.14159;void Showarea (double R); void Showarea (double r,int precision); int main () { double R; int precision; cin>>r>>precision; Showarea (r); Showarea (r,precision); return 0;} void Showarea (Double r) { double S; S=pi*r*r; Cout<<setiosflags (ios::fixed) <<setprecision (2) <<s<<endl;} void Showarea (double r,int precision) { double S; S=pi*r*r; Cout<<setiosflags (ios::fixed) <<setprecision (precision) <<s<<endl;}
Operation Result:
OJ "Default parameter--the area of the circle"