// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public struct Pair { public int A; public int B; } public class Program { public static Pair Split(int total, Pair rel) { Pair res; res.A = total * rel.A / (rel.A + rel.B); res.B = total - res.A; return res; } public static void Main(string[] args) { Pair one; one.A = 1000000; one.B = 4000000; Pair two = Split(1000, one); Console.WriteLine(two.A + " " + two.B); Console.ReadKey(); } } }