Results 1 to 7 of 7

Thread: string parsing please help me

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    5

    string parsing please help me

    i got to take an linear equation from user and i got seperate variables and contants and tight hand side of the equation in seperate arryas
    example x1+2y1-3z1=30

    arrayconst=(1,2,3)
    arrayvar=(x1,y1,z1)
    arrayoper=(+,-)
    RHS=30
    ope="="

    any type of variable can come in to the equation
    please help

    kalyan boinapalli

  2. #2
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    321
    can you put in spaces in between the formulae? that would make things a little easy. is the format posted final? no spaces in between?

  3. #3
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    321
    does the linear equation always have the same form as you posted before?

    does it include only 3 variables as stated before?

    pls include more details

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    5
    thank you
    i can put spaces in between ,but the no of variables vary
    thanks again

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    5
    the equation length may vary

    any thing can come like x1+x2-y+z>=30

    and we can include spaces to seperate different words

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Create an Array containg Variables (a tru z), and an Array containing
    Constants (+ , -). Slice the string and loop thru the 2 arrays.
    From that build up your three Arrays.

  7. #7
    ruyeno22
    Guest

    looks like a compiler

    are you gonna consider the bad users that put something like "xy++"?

    maybe you can create an array of invalid values, constants, and operators. then all you have to do is read char by char and look for it in an array.
    if its in the invalid values you can raise a message. if its in the constants you can put it in a constants array, you do the same with the rest of the caracters...

    damn! i really dont remember how to do that the "by the book" way.... maybe you can look on the web for "compilers". lexical, syntactic and semantical analysis and so on...

    sorry if i misspelled some words

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width