int main() { char t; double a,b,c; double root1,root2; while(1) { cout<<"input q to quit, any other char to continue \n"; cin>>t; if(t=='q') break; cout<<"input the coefficients a b c of the form ax^2+bx+c\n"; cin>>a>>b>>c; double discriminant=compute_discriminant(a,b,c); if(a==0&&b!=0) { linear_equation(b,c,root1); cout<<"this is a linear equation with the root= "<<root1<<endl; cout<<"the computational error is "<<compute_error(a,b,c,root1)<<endl; } if(a==0&&b==0) { cout<<"this equation has no real roots\n"; } if(discriminant==0&&(a||b!=0)) { double_real_root(a,b,c,root1); cout<<"this is an equation with a double real root= "<<root1<<endl; cout<<"the computational error is "<<compute_error(a,b,c,root1)<<endl; } if(discriminant>0&&a!=0) { two_real_roots(a,b,c,discriminant,root1,root2); cout<<"this equation has two real roots = "<<root1<<" and "<<root2<<endl; cout<<"the computational error for root 1 is "<<compute_error(a,b,c,root1)<<endl; cout<<"the computational error for root 2 is "<<compute_error(a,b,c,root2)<<endl; } if(discriminant<0) { complex<double> com_root1; complex<double> com_root2; no_real_roots(a,b,c,discriminant,com_root1,com_root2); cout<<"this equation has two imaginary roots = "<<com_root1<<" and "<<com_root2<<endl; } } keep_window_open(); return 0; }
EXPORT void* expression_equals_double(void* e1, double v) { linear_expression le1 = *reinterpret_cast<linear_expression*>(e1); linear_expression le2 = linear_expression(v); constraint* c = new constraint(linear_equation(le1, le2)); return reinterpret_cast<void*>(c); }