You are on page 1of 3

A.

Balance number

The balance number is a 4-digit number, where the sum of the first two digits is equal to the sum of
the remaining two digits.
Creates a program that allows user enter a 4-digit positive integer, and checks if it's a balance number
or not a balance number.
Input
The input starts with an integer N (1000 ≤ N ≤ 9999).
Output
Prints “Yes” since N is a balance number, otherwise print “No”.
Sample
Sample Input 1 Sample Output 1
1000 No

Sample Input 2 Sample Output 2


1230 Yes

Sample Input 3 Sample Output 3


2213 Yes

Sample Input 4 Sample Output 4


2233 No
B. The rating over average
The percentage of students who scored above the grade point average.
Creates a program that allows user to enter N students, calculates the grade point average (A), counts
the number of students with higher scores than the grade point average (M), then prints ratio of
numbers greater than average (M/N *100%)
Input
The first line contains the number of student in the class N (1 ≤ N ≤ 50).
The second line, containing N integers a0, a1, ..., aN-1 (0 ≤ i ≤ N-1, 0 ≤ ai ≤ 100). They are the final
grade of N students in the class.
Output
The percentage of students whose grade is above average, rounded to exactly 3 decimal places.
Sample
Sample Input 1 Sample Output 1
5 40.000
50 50 70 80 100

Sample Input 2 Sample Output 2


7 57.143
100 95 90 80 70 60 50

Sample Input 3 Sample Output 3


3 33.333
70 90 80

Sample Input 4 Sample Output 4


3 66.667
70 90 81

Sample Input 5 Sample Output 5


9 55.556
100 99 98 97 96 95 94 93 91
C. Remove duplicate characters

Creates a program that allows user entering a name and removes all consecutive duplicate characters.
Input
The input contains a single name that contains only lowercase letters (a–z), no white space. The length
of name is from 1 to 250 characters.
Output
The normalized name.

Sample
Sample Input 1 Sample Output 1
robert robert

Sample Input 2 Sample Output 2


rooobert robert

Sample Input 3 Sample Output 3


roooooobertapalaxxxxios robertapalaxios

You might also like