Balancing chemical equation

Discussion in 'Programming' started by dejandenib, Aug 5, 2009.

  1. #1
    Can anyone help me with this?
    the program should output how can the chemical equation be balanced (which are the coefficients)
    28th ACM International Collegiate Programming Contest, 2003-2004 Asia Region, Tehran Site
    Balanced Chemical Equations
    Sample Input
    3
    HCl+CaO2H2=CaCl2+H2O
    HCl+H2SO4=NaCl
    HCl+NaOH=NaCl+H2O
    Sample Output
    2 1 1 2
    IMPOSSIBLE
    1 1 1 1
     
    dejandenib, Aug 5, 2009 IP
  2. runspace

    runspace Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well what are you given? I need a more specific description of the problem and what you are trying to solve before I can provide specific advice. Do you need to write the program in a specific language?

    I would think you would want to create a variable for each element in the equation. Then you will most likely need to figure out if the elements are on the left or right side of the equal sign. Following this you will need to determine which of the elements need to be balanced on the right side of the equation and multiply by an appropriate coefficient to balance these elements.
     
    runspace, Aug 5, 2009 IP
  3. gbit

    gbit Active Member

    Messages:
    625
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    70
    #3

    There chemical balancing scripts available freely in the market.
     
    gbit, Aug 6, 2009 IP
  4. dejandenib

    dejandenib Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well you can see what is given in input and i want it in c++, c, pascal or Java.
    And where can i find those scripts free on the market
     
    dejandenib, Aug 6, 2009 IP
  5. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #5
    You would not find C++ code for your chemistry homework for free anywhere.
     
    it career, Aug 6, 2009 IP
  6. dejandenib

    dejandenib Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    but maybe someone had the official solutions of 28th ACM International Collegiate Programming Contest, 2003-2004 Asia Region, Tehran Site
    and is not for homework, it's just for fun
     
    dejandenib, Aug 6, 2009 IP