Some more C++ help needed.

Fire

CAGiversary!
[/quote]# In this project, you will write a program that will factor a trinomial of the form ax2 + bx + c
# Here are some assumptions you should make:

* a, b, and c are all integers.
* a is positive.
* c is nonzero.

# Remember that if ax2 + bx + c = (d1 + e1)(d2 + e2), then a = d1d2 and c = e1e2. This means that both d1 and d2 are to be divisors of a, and e1 and e2 are to be divisors of c. This gives you a method of checking for values of d1, d2, e1, and e2.
# Keep in mind also that you have to consider both positive and negative values of e1 and e2.
# The input will be the coefficients for the trinomial. You will output the factorization (if it can be factored), or a message indicating that it cannot be factored. [/quote]

I'm lost on this one. I understand what it is looking for, but I'm not even sure where to start or what to do.
 
WOW....... ....man I'd help you but I haven't done anything in C++ in a loong time.

I will give it a whirl though, is this a lab for a class or something your doing for fun?

bill123
 
Where to start:
#include
using namespace std;
int main(int argc, char** argv)
{
return 0;
}
:D

Seriously though, what are you having trouble with? Do you actually have to use their factorization method or is it just a suggestion?
 
[quote name='Fire']# In this project, you will write a program that will factor a trinomial of the form ax2 + bx + c
# Here are some assumptions you should make:

* a, b, and c are all integers.
* a is positive.
* c is nonzero.

# Remember that if ax2 + bx + c = (d1 + e1)(d2 + e2), then a = d1d2 and c = e1e2. This means that both d1 and d2 are to be divisors of a, and e1 and e2 are to be divisors of c. This gives you a method of checking for values of d1, d2, e1, and e2.
# Keep in mind also that you have to consider both positive and negative values of e1 and e2.
# The input will be the coefficients for the trinomial. You will output the factorization (if it can be factored), or a message indicating that it cannot be factored.

I'm lost on this one. I understand what it is looking for, but I'm not even sure where to start or what to do.[/QUOTE]


This is more of an algorithm problem than actual coding, right?

The input should not be difficult; read in three integers and store them. The output once found isn't tough either ...

The first thing you should do is have a loop from 1 to a/2, which will check to see all the factors of a. i.e., something like ...

note: we add a "+1" to our loop control variable because C++ truncates decimals; thus if a = 5, then a/2 = 2.5, truncated to 2. We need to check at least one more value so we add in the plus 1.

for(i=1; i
 
I'm not entirely certain what they're looking for. It's been a long time since algebra. I'll ask a math teacher I know for the simplest factorization method. She may be able to help.
 
bread's done
Back
Top