I am getting a runtime error for my code shown below.....cant figure out what is the problem it works fine on my compiler. question:A cricket team consists of 11 players and some are good at batting, others are good at bowling and some of them are good at both batting and bowling. The batting coach wants to select exactly K players having maximum possible sum of scores. Given the batting score of each of the 11 players, find the number of ways in which we can select exactly K players such that the sum of their scores is the maximum possible. Two ways are different if there is a player who is selected in one of them is not in the other. See explanation of sample cases for more clarity. Input First line contains T, number of test cases ( 1 â?¤ T â?¤ 100 ). T cases follow, each having 2 lines. First line of each case contains scores of 11 players ( 1 â?¤ score â?¤ 100 ) and the second line contains K (1 â?¤ K â?¤ 11) Output For each test case, output the answer in a new line. Example Input: 2 1 2 3 4 5 6 7 8 9 10 11 3 2 5 1 2 4 1 6 5 2 2 1 6 Output: 1 6 my approach: is first to sort the array of batsmen then select k out of them as per decreasing score. the last group(1 or more) of batsmen selected having the same scores will result in increased no of ways if there are othe rs having the same score but are not selected. so the no of ways comes only from the above group( last group: selected + non selected ). No of ways= C(total,selected) where total= selected + non selected. include<stdio.h>int cal_fact(int num); int get_arr(int arr); void sort_arr(int arr); void swap(int a,int b); int calc_ways(int *arr,int k); void main(){
} int cal_fact(int num){
} int get_arr(int *arr){int i; for(i=0;i<11;i++){ scanf("%d",&arr[i]); } } void sort_arr(int *arr){ int i,j;
} void swap(int a, int b){
} int calc_ways(int *arr,int k){
} asked 01 Oct '12, 16:05
