المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Read coefficients of linear equations into 2d array



C++ Programming
06-20-2009, 03:51 PM
Hi,
I'm working on a program that reads linear equations from a file such as those: 3x+2y-2.5z=9
-2x+9y+12z=23.4
4.2x-7y+9.6z=45.3

The file is supposed to contain n equations with n variables which I would read into a 2d dynamic array of doubles and then I'm supposed to solve the resulting matrix using Gauss's method. I've already implemented Gauss's method but I can't figure out when reading from file how to get only the numbers and the signs for example from the above equations I'm supposed to have the following in the array: [+3][+2][-2.5]
[-2][+9][+12]
[+4.2][-7][+9.6]

I need the numbers after the equal sign to be stored in a separate n sized array as well.

If anyone has any ideas I'd really appreciate it http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif