60 likes | 186 Views
This document explains multiple programming problems focused on implementing functions for computing maximum values, handling matrices, and developing game logic. Problem 1 requires you to write the `maxv()` function to determine the maximum value from an input array. Problem 2 involves handling arrays of numbers and performing calculations to produce output values. Problem 3 requires matrix operations, including transposing and calculating the determinant. Problem 4 introduces a simple game mechanism where a human player competes against a computer based on scores and rolling dice.
E N D
Problem 1 • You should write maxv() function (Exercise 11 on page 297). • Testcase: • Testcase 1: • Input : 1 2 3 4 5 -1 • Output : maximum value was v[4] = 5 • Testcase 2: • Input : 5 1 3 4 2 -1 • Output : maximum value was v[0] = 5
Problem 2 • Test case • Input 135 1 45 1 45 1 -45 1 -1 -1 • Output • 90 • 1.4142 • 0 • 1.4142 You can create your own test case using the form in http://www.1728.org/vectors.htm.
Problem 3 • Input • 1 2 3 4 5 6 7 8 9 • Output • The matrix is1 2 34 5 67 8 9Transpose of matrix is1 4 72 5 83 6 9Determinant of matrix is0
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.