Simple logic problem: Finding largest and smallest number among 3 numbers
问题 I am creating a pseudocode in determining the smallest and largest number among 3 numbers: My code is as follows: If (x >= y) largest = x Smallest = y Else largest = y Smallest =x If (z >= largest) Largest = z If (z <= smallest) Smallest = z Do you think this is correct? or are there better ways to solve this? 回答1: Let's say you've got arbitrary numbers x, y, z . Pseudocode: largest = x smallest = x if (y > largest) then largest = y if (z > largest) then largest = z if (y < smallest) then