Q1 (30 pts)
Write a program which reads a sequence of characters until enter (‘\n’). Your program must output the most repeated character within the sequence.
Notes: characters are 8-bit standard characters. No encoding other than ascii will be used. Additionally, you can assume that all entered characters until \n will be printable characters (characters with ascii code between 32 and 126 (32<=x<=126) are called printable characters).

Input:
rrtyyafkdlaaahteeeeeaaraauy
Output:
Max repeated character is 8 times a

Input:
++AAaGggttTT--;;;,,rrRRRRrrRRee<<><<<<<<<<<<)yy
Output:
Max repeated character is 12 times <

Q2 (10 pts)
What does the following function do?
void f(char *a, char *b){
     while(*a++ = *b++){}
}

Q3 (60 pts)
Two treasure hunters found a chest with many gold coins in it. They decided to share the chest as just as possible. But they saw that the gold coins are not all equal. Some are heavier, some are lighter. Thus they need to make two groups of coins in such a way that, the sum of weights of golds within the first group must be as equal as possible to the sum of weights of golds within the second group. They came to you and wanted from you to write a program for seperating the coins. Your program will read the weights of coins until the user enters 0. Then your program finds the most equal seperation and prints the seperation, and the difference between groups.
Assumptions:
-You can assume that the user will not enter a negative value.
-You can also assume that the number of coins will be at most 1000.
Notes: This is an NP-complete program (http://en.wikipedia.org/wiki/NP-complete). Which means it does not have a much better solution than checking all possible seperations. Your answer will be graded according to two criterias: The correctness of your program (30 pts) and the speed of your program (30 pts).

Input:
34 2 12 4 55 4 3 8 9 90 12 0
Output:
group1: 2 3 9 90 12
sum group1: 116
group2: 34 12 4 55 4 8
sum group2: 117
difference: 1

Input:
1 2 1 1 43 1 4 5 2 2 0
Output:
group1: 1 2 1 1 1 4 5 2 2
sum group1: 19
group2: 43
sum group2: 43
difference: 24

Input:
0
Output:
group1:
sum group1: 0
group2:
sum group2: 0
difference: 0

 

Good Luck !