Week 9 computer task Project 5: Find the root of the mona1 quadratic equation

Source: Internet
Author: User
01. /* 02. * copyright (c) 2012, School of Computer Science, Yantai University 03. * All Rights Reserved. 04. * Author: Zhao guanzhe 05. * Completion Date: July 6, October 25, 2012. * version No.: V1.0 07. * input Description: Root 08 Of The unary quadratic equation. * Problem description: Root 09 of a quadratic equation. *ProgramOutput: Two roots of the equation 10. * Problem Analysis: first judge whether it is a quadratic equation, and then judge whether there is a real root 11 .*AlgorithmDESIGN: 12. */13. # include <iostream> # include <cmath> using namespace STD; int main () {float a, B, c, x1, x2; cout <"enter, value of B and C: "; CIN> A> B> C; if (a = 0) {x1 = x2 = (-C)/B; cout <"X1 =" <X1 <Endl; cout <"X2 =" <X2 <Endl ;} else {If (B * B-4 * a * C> = 0) {x1 = (-B + SQRT (B * B-4 * a * C)/(2 * ); x2 = (-B-SQRT (B * B-4 * a * C)/(2 * A); cout <"X1 =" <X1 <Endl; cout <"X2 =" <X2 <Endl;} else {cout <"This equation has no solid root" ;}} return 0 ;}

Running result:

Experience:

This week's task may feel a little difficult, and more people feel that they will not be too much. They should be prepared in a timely manner. Learn more.

Knowledge Point summary:

This task involves the if branch statement. Note the use of parentheses.

Related Article

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.