Hi, I'm new here and relatively new to c++ as well. I'm trying to write a function which will solve a quadratic equation. The progran needs to distinguish which coefficient is a, b and c. The quadratic is on the command line at argv[2].
So I decided to split the string (quadratic) up to the x
e.g. 4x^2 + 3x + 5
I want the code to read up to x^2 and place the value into a vector. It will then ignore everything until the +/- and then read the value until the x and place that into a vector; once again ignore everything until it passes the +/- and then read the c constant and place that into a vector.
I would prefer to use an array to store the a, b and c values. Can anyone help me with a code to run through the string and extract the required values?
Another issue is this:
Provided i can use an array, can i initialize the array as follows:
arr[0] = a
arr[1] = b
arr[2] = c
where a, b and c can take any values as specified by the user?
Any help would be greatly appreciated.
So I decided to split the string (quadratic) up to the x
e.g. 4x^2 + 3x + 5
I want the code to read up to x^2 and place the value into a vector. It will then ignore everything until the +/- and then read the value until the x and place that into a vector; once again ignore everything until it passes the +/- and then read the c constant and place that into a vector.
I would prefer to use an array to store the a, b and c values. Can anyone help me with a code to run through the string and extract the required values?
Another issue is this:
Provided i can use an array, can i initialize the array as follows:
arr[0] = a
arr[1] = b
arr[2] = c
where a, b and c can take any values as specified by the user?
Any help would be greatly appreciated.
Comment