Jump to content

Expression Evaluation:Urgent help needed

- - - - -

  • Please log in to reply
4 replies to this topic

#1
avm08

avm08

    Newbie

  • Members
  • Pip
  • 2 posts
input

output


[0]

0

[1]

1

[0,1]

1

[1,1]

2

[1,[1,2]]

-2

[1,2,[8]]

-5

[1,[2],[3]]

-4

[9,[3,4,[[2]]]]

0

[2,[[2]]]

4


Write Function for it.

public int ExpressEval(string expression)

i.e
if input string is "[1,2,[5,3]]" then ur function must return -5.
I need this code urgently,so plz try helping me :confused:

#2
Vladimir

Vladimir

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Why [2,[[2]]] = 4? Should not it be 0?

#3
avm08

avm08

    Newbie

  • Members
  • Pip
  • 2 posts
since [[2]] has 2 sets of brackets, its value is added.
E.g [1,[1,2]] = -2 and
,[3,4,[[2]] = 9

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
*sniff* *sniff* Yup... Just as I suspected. Smells like homework.
-CDG10620
Software Developer

#5
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Couldn't agree more
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users