// CMSC 100 UNQUIZ -- 9/25/08 // Function that returns True if all three of its inputs // are the same, else returns False function Check (Num1, Num2, Num3) { if ( Num1 == Num2 ) then { if ( Num2 == Num3 ) then { return (TRUE) } else { // This "else" matches the inner "if" -- // if ( Num2 == Num3 ) return (FALSE) } } else { // This "else" matches the outer "if" -- // if ( Num1 = Num2) return (FALSE) } } // Another way to write the Check function, using the logical // (Boolean) && (AND) operator so we just need one "if" statement function Check (Num1, Num2, Num3) { if ( ( Num1 == Num2 ) && ( Num2 == Num3 ) ) then { return (TRUE) } else { return (FALSE) } } // Procedure that takes a list of numbers and prints // the number of negative numbers, the number of zeros, // and the number of positive numbers in the list. // Note that "N" here refers to the length of the list // (that is, the number of items in the list). procedure Counts (List[N]) { count1 := 0 count2 := 0 count3 := 0 for i from 1 to N do { if ( List[i] < 0 ) then { count1 := count1 + 1 } else if ( List[i] == 0 ) then { count2 := count2 + 1 } else { count3 := count3 + 1 } } print (count1, count2, count3) }