#include <iostream> #include<stdio.h> #include<math.h> #include<string.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { double a , b , c; double desc; scanf("%lf %lf %lf" , &a , &b , &c); desc = b * b - 4 * a *c; double x1 = ( -b + sqrt( desc ) ) /(2 * a); double x2 = ( -b - sqrt( desc ) ) /(2 * a); if( x1 < x2){ double t = x1; x1 = x2 ; x2 = t; } printf("x1= %.2lf , x2 = %.2lf " , x1 , x2); return 0 ; } |
Double click to view unformatted code.