struct cat { string name, color; int legs, weight, value; }; void set(cat & C, string n, string c, int l, int w, int v) { C.name = n; C.color = c; C.legs = l; C.weight = w; C.value = v; } void print(cat C) { cout << C.name << ", " << C.color << ", " << C.legs << " legs, " << C.weight << " lbs, " << C.value << " cents\n"; } struct member { string name, address; cat one, two, three; }; void set(member & M, string n, string a, cat on, cat tw, cat th) { M.name = n; M.address = a; M.one = on; M.two = tw; M.three = th; } void print(member M) { cout << M.name << ", of " << M.address << "\n"; cout << " cat 1 "; print(M.one); cout << " cat 2 "; print(M.two); cout << " cat 3 "; print(M.three); } int fight(cat a, cat b) { if (a.legs == 4 && b.legs != 4) return 1; if (b.legs == 4 && a.legs != 4) return 2; if (a.weight > b.weight) return 1; if (b.weight > a.weight) return 2; if (a.value < b.value) return 1; if (b.value < a.value) return b; return random_in_range(1, 2); } void contest(member & A, member & B) { int w1 = fight(A.one, B.one); int w2 = fight(A.two, B.two); int w3 = fight(A.three, B.three); int ones = 0, twos = 0; if (w1 == 1) ones += 1; else twos += 1; if (w2 == 1) ones += 1; else twos += 1; if (w3 == 1) ones += 1; else twos += 1; if (ones > twos) B.name = "Mr Loser"; else A.name = "Mr. Loser"; } /* { cat joey, t, x; set(joey, "Joey", "Tabby", 4, 7, 500); set(t, "Timmy", "Tabby", 4, 5, 5000); set(x, "Stumpy", "Grey", 3, 6, 0); print(joey) // prints Joey, Tabby, 4 legs, 7 lbs, 500 cents member a; set(a, "Mrs Smith", "123 Ant St", joey, t, x); print(a); int winner = fight(joey, t); */