Week 8: Monday -------------- Q1. (50) Suppose two players are playing a simple game of dice. Each player rolls the die twice. The winner is decided based on the following rules: * If one player has got the same number twice and the other player has not got the same number twice, then the first player wins * If both players have got the same number twice, the player with the larger of the numbers wins * If none of the players have got the same number twice, the player with the larger sum of numbers wins * Otherwise, it is a tie Simulate the above game. Ensure that the two players do not get the same two numbers in sequence. They may get the same two numbers out of sequence, i.e., (2,3) and (2,3) are not allowed, although (2,3) and (3,2) are allowed. This automatically means that (2,2) and (2,2) are not allowed. Print the numbers rolled by both the players. Declare the winner. In case of a tie, declare a tie. Use the function rand() that returns a random integer. You can use this function to generate a random integer within a particular range. For example, to generate a random integer between 1 and 10, you need to use (1 + rand() % 10). Q2. (50) Input an array of integers of size 9. Assume that all the elements of the array are distinct. Find the median. The median of a set of integers is the number that is right in the middle, i.e., the number of numbers lesser than it and the number of numbers greater than it are the same. For an array of size 9, it is the 5th element when the array is sorted. You cannot sort the array to find the median.