HW4 Explanation
Problem 1 You should write maxv() function (Exercise 11 on page 297). Testcase: – Testcase 1: Input : Output : maximum value was v[4] = 5 – Testcase 2: Input : Output : maximum value was v[0] = 5
Problem 2 Test case – Input You can create your own test case using the form in g/vectors.htm. g/vectors.htm Output
Problem 3 Input – Output – The matrix is Transpose of matrix is Determinant of matrix is 0
Problem 4 The first player to get to 50 points wins. Human player enters R or H to signal whether to Roll or to Hold. The computer player will always hold after 4 rolls unless its turn ends early due to a 1. After each roll, print the current sequence of scores and the current sum. If the player rolls a 1, the program prints "1 rolled, turn is over" and then the current score for both players.
Problem 4 PlayerDice outputScore Computer2C=2, P=0 Computer1C=0, P=0 Player, R4C=0, P=4 Player, R5C=0, P=9 Player, R6C=0, P=15 Player, R3C=0, P=18 Player, H-C=0, P=18 Computer3C=3, P=18 Computer4C=7, P=18 Computer2C=9, P=18 Computer2C=11, P=18 Player, R2C=11, P=20 Player, R1C=11, P=18