Rwkj 1363 square rectangular Triangle Area

Source: Internet
Author: User
Tags cmath

 

 


C ++: overload function 2 (calculated area)
Time limit (Common/Java): 1000 ms/3000 Ms running memory limit: 65536 Kbyte
Total submissions: 370 pass the test: 241

Description


Defines the overload function area () to calculate the area of the square, rectangle, and triangle respectively.


Input


There are 3 rows in total.

There is a real number in the row 1st, which is the side length of the square;

The second row has two real numbers, which are the two sides of the rectangle;

The fifth row has three real numbers, which are the three sides of the triangle.


Output

Area of a square, rectangle, or triangle (with three decimal places retained ).

Sample Input

3.5
4.2 5.62
3.0 4.0 5.0

Sample output

12.250
23.604
6.000

 

 

 

 

 


# Include <iostream>
# Include <iomanip>
# Include <cmath>
Using namespace STD;
Double area (double)
{
Return a *;
}
Double area (double A, double B)
{
Return a * B;
}
Double area (double A, double B, double C)
{
Double S;
S = (A + B + C)/2;
Return SQRT (S * (S-A) * (S-B) * (s-c ));
}
Int main ()
{
Double A, B1, B2, C1, C2, C3;
Cin>;
Cin> B1> B2;
Cin> C1> c2> C3;
Cout <fixed <setprecision (3) <area (a) <Endl;
Cout <fixed <setprecision (3) <area (b1, b2) <Endl;
Cout <fixed <setprecision (3) <area (C1, C2, C3) <Endl;
Return 0;
}

 

 

 

# Include <iostream>
# Include <iomanip>
# Include <cmath>

Using namespace STD;

Int main ()
{
Double A, B, C, D, E, F, T;
Double S1, S2, S3;
Cin> A> B> C> D> E> F;
S1 = A *;
S2 = B * C;
T = (D + E + F)/2;
S3 = SQRT (T * (t-d) * (t-e) * (t-f ));
Cout <fixed <setprecision (3) <S1 <Endl;
Cout <fixed <setprecision (3) <S2 <Endl;
Cout <fixed <setprecision (3) <S3 <Endl;
Return 0;

}

 

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.