math - My c++ code for factoring isn't working -


I am trying to create a C ++ program, when I input two numbers (num1, combination no ), It finds two numbers which multiply simultaneously is equal to 1, but add together with the same combination it currently works for positive integer, but is not negative how do I work with negative integers I can? In addition, if the equation is not being solved, I would like to print it some kind of error. Thanks! Code:

  // // Main CPP // Factor // Created on 2/13/14 by Daniel Smith // Copyright (C) 2014 Danny Smith Productions All Rights Reserved. // # include & lt; Iostream & gt; # Include & lt; Semith & gt; using namespace std; Zero factor (integer number, integer number) {int a, b; Cout & lt; & Lt; "Are the factors"; Bool isPrime = true; Int root = (int) sqrt ((double) num); (I.e. i = l;; i ++) for (if (num% i == 0) {isPrime = false; // court << i  gt; 1; Cout & lt; & lt; "What do you want to add to them? ? \ N "; Cin>> CombinationNum; factor (s) Back to top 0;}  

To resolve: < / P>

  x + y == ax * y == b  

you have to solve

  y == a - Xx * x - a * x + b == 0   

Therefore with delta == a * a-4 * b , if delta Positive, Solutions

x1 = (a + sqrt (delta)) / 2x2 = (a + sqrt (delta)) / 2

Code: ()

  zero resolution (int sum, int mul) {std :: cout & lt; & Lt; "Solution for x + y =" & lt; & Lt; Amount & lt; & Lt; Std :: endl & lt; & Lt; "X * y =" & lt; & Lt; Mul & lt; & Lt; Std :: endl; Const int delta = sum * sum - 4 * mul; If (delta & lt; 0) {std :: cout & lt; & Lt; "No solution" & lt; & Lt; Std :: endl; Return; } Const float sqrtdelta = sqrtf (delta); Const float x1 = (zodiac + sqrtdelta) / 2.f; Const float x2 = (zodiac - sqrtdelta) / 2.f; Std :: cout & lt; & Lt; "X =" & lt; & Lt; X1 & lt; & Lt; ", Y =" & lt; & Lt; Zodiac - x1 & lt; & Lt; Std :: endl; If (delta! = 0) {std :: cout & lt; & Lt; "X =" & lt; & Lt; X2 & lt; & Lt; ", Y =" & lt; & Lt; Zodiac - x2 & lt; & Lt; Std :: endl; }}  

Comments