Dear all,
I have been working on a project, I am still at the beginning, one of the tasks is to take a number of equations from the user line by line
example :
3x1+4x3+3x2=12
4x2+4x1+2x1=13
and so on, I should rearrange these equations as follow: x1, x2, x3...
the rest of the project is to apply operations on these equations and finally solve them.
I have managed to take the equations and add them to an array now I am trying to rearrange them inside the array, also I need some help in generalizing my work.
Thanks in advance
Sorry for the inconvenience as this is my first post.
and actually it is intended to be( x1,x2) it was asked like this in the project I know it is confusing but that what they want.
I think it's better to read the data into an int (or float) vector and forget about the strings. Then the index of the element represents the subscript and the value is the coefficient. (see code below)
First of all, thank you very much for your code as it saves a lot of work.
could please help me understand it more, I don't know how to access these equations to apply operations on them like,
adding or subtracting equations when user enter ( add 1 3)
print coefficients of x1 when ( column x1)
finally solving these equations using Cramer rule
How can I end your code to see the result ? I am very sorry for my ignorant.
There is something I forgot to add in the main post I am able to take the number of equations from the user at the beginning
I'm not sure how much I can explain to you. The subscripts have become the coef array's indices. So to add one to the first equation's subscript 2 coefficient you would say:
++eq[0].coef[2];
Maybe you can understand an array-based version better. This version has a maximum number of equations and coefficients-per-equation, though (both set to 20 below).
I am very Thankful to you, that was very helpful.
tomorrow I will try to add the operations and solve the equations.
If I need help can I replay here in this post ?
Dear tpb,
I dont know how to ask the user for my operations(see comments)
somthing I couldnt do is to make 1x1 == +x1 and -1x1== -x1 (make the one optional)
^{}could you help me with optional one problem and there should be no multiples if user entered 2 of x1 they should be added up and if he entered 2 results they should be added up
ex: 2x1+3x2-x1-12=10 should be 1x1+3x2=22
Thanks in advance