OJ Final Brush question B: Finding the triangular area-gyy

Source: Internet
Author: User

Title Description

Enter the length of the three edges, if the three edges can form a triangle, you need to calculate the Triangle area, and if you cannot form a triangle, output the hint message "error input". Output area is output as two decimal places

Input

Length of three sides

Output

If these three edges can form a triangle, the area of the triangle is output, and if the three edges do not form a triangle, the output cue message "Error input"

Sample input
3.3  4.4  5.5
Sample output
area=7.26
Tips

Retain two decimal places when output area

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <iomanip>using namespace std; int main () {    double a,b,c,l,s,m;    cin>>a>>b>>c;    L= (A+B+C)/2;    m=l* (l-a) * (l-b) * (l-c);    if (a+b>c&&a-b<c&&b-a<c)    {        s=sqrt (m);        cout<< "Area=" <<setiosflags (ios::fixed) <<setprecision (2) <<s;    }    else        cout<< "error  input";        return 0;}


Operation Result:

Learning experience:

Good study Day Day up








OJ Final Brush question B: Finding the triangular area-gyy

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.