Rwkj 1354 circle perimeter and area

Source: Internet
Author: User

C ++: class and object 2 (circumference and area of the circle)
Time limit (Common/Java): 1000 ms/3000 Ms running memory limit: 65536 Kbyte
Total submissions: 1038 pass the test: 524

Description


Write a program using the class, enter the radius of the circle, and calculate and display the circumference and area of the circle. Circumference rate: 3.14


Input

The input contains N groups of test instances. Row 1st is the number of test groups.

Row 10-row n + 1 test data. Each group of test data has a real number, indicating the radius of the circle.


Output

The circumference and area of the circle (retain 2 decimal places ).

Sample Input

3
4.5
14.6
5.5

Sample output

28.26 63.59
91.69 669.32
34.54 94.98

 

 

 


# Include <iostream. h>
# Include <iomanip. h>
Class circle
{
Double R;

Public:
Circle (Double X)
{R = x ;}

Void disp ()
{
Cout <fixed <setprecision (2 );
Cout <3.14 * r * 2 <"" <3.14 * r <Endl;
}
};


Int main (INT argc, char * argv [])
{
Int N;
Double R;

Cin> N;

While (n --)
{
Cin> r;
Circle C (R );
C. disp ();
}
}

 

**************************************** * ************* 8

 


# Include <iostream. h>
# Include <iomanip. h>
Class circle
{
Double R, C, S;

Public:
Circle (Double X)
{R = x; C = 3.14 * r * 2; S = 3.14 * r ;}

Void disp ()
{
Cout <fixed <setprecision (2 );
Cout <C <"<S <Endl;
}
};


Int main (INT argc, char * argv [])
{
Int N;
Double R;

Cin> N;

While (n --)
{
Cin> r;
Circle C (R );
C. disp ();
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.