using System.Collections; using System.Collections.Generic; using UnityEngine; public class Biggest : MonoBehaviour { // Start is called before the first frame update void Start() { int x = BiggestOfTwo(5, 8); Debug.Log("Of 5 and 8 the biggest is " + x); int y = BiggestOfTwo(x, 9); Debug.Log("Of 5, 8 and 9 the biggest is " + y); Debug.Log("Of 5, 8 and 9 the biggest is " + BiggestOfThree(5,8,9)); Debug.Log("Of 5, 8 and 9 the biggest is " + BiggestOfThreeUsingTwo(5, 8, 9)); } int BiggestOfTwo(int a, int b) { if (a > b) { return a; } return b; } int BiggestOfThree(int a, int b, int c) { if (a > b) { if (a > c) { return a; } return c; } // b > a if (b > c) { return b; } return c; } int BiggestOfThreeUsingTwo(int a, int b, int c) { int firstTwo = BiggestOfTwo(a, b); return BiggestOfTwo(firstTwo, c); } }