Question:
How to create a C++ program the can accept a set of n linear equations with n unknown variables each.?
1970-01-01 00:00:00 UTC
How to create a C++ program the can accept a set of n linear equations with n unknown variables each.?
Three answers:
2016-10-06 11:41:57 UTC
Divide via n^a on the two factors one million + n^(b - a) = n^(c - a) n^(b - a) + one million = n^(c - a) we are able to factor this. (n + one million)(n^(b - a - one million) - n^(b - a - 2) ... ) = n^(c - a) enable n^(b - a - one million) - n^(b - a - 2) ... = S S(n + one million) = n^(c - a) S = n^(c - a) / (n + one million) S could desire to be an integer if a, b, c, n are integers. considering that n^(c - a) basically has n as a factor, n + one million won't be able to be a factor. If n + one million isn't a factor, S isn't an integer, consequently a, b, c, n won't be able to be integers. ----- EDIT: simply by Lobosito's edit, i will edit my answer. n^(b -a) = n^(c - a) - one million we are able to factor the RHS and then from branch via n - one million, we teach that a, b, c, n are no longer integers.
2009-08-20 04:50:21 UTC
As part of the program ask the user how many unknowns, or count as you accept input. You can then dynamically get enough memory to accommodate all the unknowns at run time.



Another way would be to solve for say 10, and then see what you have to do to remove the limitation.



The point is that you are building in as few limitations for your program as possible.
2009-08-20 05:05:29 UTC
You may want to consider using a linked list to build the equation, something like



struct Element

{

char type; // variable, operator, etc. enum would be good here

char value;

Element *pNext;

};



That way you can build it and not be dependant on how many factors there are.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...