View Single Post
Join Date: Jan 2008
Posts: 3,819
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Calculating resistance

 
0
  #8
Nov 20th, 2008
I see how you got 100. I would say that you are assuming a lot if you are assuming that people will know that that is the circuit you are intending with that input. You should spell out the rules a little more, in my opinion, but if everyone knows how to enter the circuit (I THINK I understand the rules and the assumptions you are making regarding how a circuit is created from the input), your calculation boils down to this:

100 + 100 + 100 = 300 (first three resistors are in series). Replace with a single 300 ohm resistor.

1 / (1/300 + 1/200 + 1/200) = 75. Replace these parallel resistors with a single 75 ohm resistor.

75 + 25 = 100 (replace these two resistors in series with a single 100 ohm resistor.

1 / (1/100 + 1/100) = 50

50 + 50 = 100, which is the answer.

So make two functions. One that takes an array of resistors in series and calculates their resistance, one that takes an array of resistors in parallel and calculates their resistance. I'd change the "starting resistor" to simply a "series" resistor, since it's the same thing in your schematic. You'll need to set up an array to read the input into, then when it changes from series to parallel or vice versa, call the appropriate function. But start with writing these functions:

  1. double SeriesResistance (int resistorValues[], int numResistors)
  2. {
  3. // returns resistance of the resistors in series
  4. }
  5.  
  6. double ParallelResistance (int resistorValues[], int numResistors)
  7. {
  8. // returns resistance of the resistors in parallel
  9. }

Then go from there. You may want to set up a struct for input since you are dealing with paired data.


Yee-ha! Post number 2000!
Last edited by VernonDozier; Nov 20th, 2008 at 3:53 am.
Reply With Quote