0

I am having four set of values,namely

 S(which ranges from x to y with a variation of .5),
 C(which ranges from a to b with a variation of .25),
 A(which ranges from p to q with a variation of 1)
 Ad(which ranges from c to d with a variation of 1.5).

For each value of S, I should get all possible combinations of values from the other three sets.Can u help me please by suggesting suitable code........

Nathan W
  • 54,475
  • 27
  • 99
  • 146
vidhya
  • 2,861
  • 5
  • 28
  • 28
  • 1
    This is not a place for asking to code for you. Better to ask for general help. – rahul Aug 24 '09 at 05:31
  • There's a great discussion on the topic of combinations in http://stackoverflow.com/questions/3093622/generating-all-possible-combinations. I'm particularly fond of Eric Lippert's solution. – mfras3r Sep 17 '12 at 15:48

1 Answers1

1

Multiply all values with some constant so that you came into "integer problem domain". Then make 4 nested loops, for Si, Ci, Ai and Adi (S-integer, C-integer, ...). This way you will get all combinations. To get back to "float domain" divide with before mentioned constant.

EDIT: Forget about previous suggestion. Try something like this:

  double x = 1.1, y = 5.1, a = 6.1, b = 7.1, p = 8.1, q = 9.1, c = 10.1, d = 15.1;
  double S, C, A, Ad;

  for (S=x; S <= y; S = S + .5)
    for (C=a; C <= b; C = C + .25)
      for (A=p; A <= q; A = A + 1.0)
        for (Ad=c; Ad <= d; Ad = Ad + 1.5)
          Console.WriteLine("S={0} C={1} A={2}, Ad={3}", S, C, A, Ad);
  Console.ReadLine();
pero
  • 4,169
  • 26
  • 27