I get equation in the form of a string from the output of a software that I want to modify further. I am no expert in C++ and I am wondering if some expert in C++ at this forum can do this for me.
Pls see the attached Notepad file. The attached file has three examples of string to be modified. Here are the attributes of the string.

a. The string will have ASCII characters in it.

b. The string is a mathematical equation. I will be pasting it into Mathcad after modification.

c. The string has parameters and mathematical operators in it (+,-,*,/,^). Each parameter is seperated from another parameter by at least one space. There is no space in a parameter. So, each parameter starts with a space and ends with a space. The parameters of the string in example 1 are listed in the attached file.

d. If a parameter has square brackets in it [], then the program will take the characters inside the brackets and disregard any character in the parameter outside the brackets. For example, it will modify the first parameter in example 1 "F_X1" as "u". If the parameter has no brackets in it, like the last parameter in example 1 (s^2), then it will take it as is.

e. The format of the string is such that the multiplication sign may be omitted between parameters. If there is no mathematical operator between two adjacent parameters, it should be assumed that the math operator between them is multiplication. So, the program should insert a multiplication sign between them.

f. Then the program will reassemple the string in the form of an equation by appropriately keeping the mathematical operators and the paranthesis in the original expression.

The program should output the "result" as shown for each example in the attached file.

I will appreciate if someone can write a program for me that accomplishes this. Many thanks.

Mark Neil

example 1:
string: (  - F[u]_X1 E[u]_X1 R[rL] - E[u]_X1 R[rL] - F[u]_X1 R[rL] - R[rL] - R[R])  s^2

parameters in the string in order:

result: (-u*u*rL-u*rL-u*rL-rL-R)*s^2

example 2:
string: ( a + b - as[h])
result:  (a+b-h)

example 3:
string: ((  - I[ko*vc] F[D] C[C] R[R] R[Resr] - I[ko*vc] H[gr] C[C] R[R] R[Resr] R[rL] + I[ko*vc] C[C] R[R] R[Resr] - I[ko*vc] H[gr] L[L] R[R]) s + (I[ko*vc] C[C] R[R] R[Resr] - I[ko*vc] H[gr] L[L] R[R]) s^2)
result: ((-ko*vc*D*C*R*Resr-ko*vc*gr*C*R*Resr*rL+ko*vc*C*R*Resr-ko*vc*gr*L*R)*s+(ko*vc*C*R*Resr-ko*vc*gr*L*R)*s^2)
9 Years
Discussion Span
Last Post by iamthwee

>I am wondering if some expert in C++ at this forum can do this for me.
No. We help you do your work, we don't do it for you. Please read the rules before posting.


This is really simple, all you really have to do is ignore the stuff before the operator(space) and the first square bracket.

Simple stuff.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.