Lab - 6 Structures
Lab - 6 Structures
Mr. Hoxha gives math lessons in a high school. He keeps his student records in a file. He normally has two
exams, two homework and two quizzes in a semester. That is a regular student takes 6 exams, but not all
students can take all the exams. Sometimes because of some personal problems students skip some exams.
Mr. Hoxha accepts excuses up to two exams. If a student has four, five or six exams, then his average is
calculated out of the exams that he has taken. But if any student takes less than four exams his average is
calculated out of four exams.
Write a program that reads the name, surname and exam information for n students and then shows the
student with the highest average.
Input specification
You will be given a number (n) at the beginning. Then n lines of student information. Every line will first
contain name and surname of the student followed by at most 6 integer grades where 1 ≤ n ≤ 100 and 1 ≤
everyGrade ≤ 100
The marks of every student ends with a negative number (-1).
Output specification
Show name surname and the floating point average of the student who has the highest average in the class.
The average must have 2 digits precision after the floating point. If there are several students with the same
max average show the first student according to the given order.
Output Explanation :
Student averages
Your math professor keeps student grades in a file. Time to time, he wants to see student lists sorted
according to averages.
Question:
Write a program that reads student names surnames and 4 marks for every student. Then, your program will
show top m students sorted in descending order according to the averages.
Input specification
The first line of the input contains two integers (n and m) where n denotes the number of students and m
denotes the number of top students to show in the output where 1 ≤ m ≤ n ≤ 600. Each of the following n
lines will have:
Name: At most 15 chars string containing only English letters.
Surname: At most 15 chars string containing only English letters.
4 Marks: 4 integer numbers between 0 and 100
Output specification
Show top m students' names surnames and averages (with 2 decimal places after the floating point).
http://acm.epoka.edu.al:8888/en/problem-pid-c4bc?ps=15&smt=8&smpwid=0
Top N Donors - 1
Shpresa Fondation collects money from its donors. And then it distributes the collected money to the people
who need. The money is collected directly from people or people donates through different banks. This year,
they want to present certificates to their Top N Donors and thus they need to put the donors in descending
order according to their total donation.
Question:
Write a program that is going to read m donors' name surname and the amount donated, and then the
program is going to list top n donors in descending order.
Note: Pay attention for the worst case running time.
Input specification
You will be first given 2 integer numbers: The number of donors (m) and the number of (n) top donors to be
listed where 1 ≤ m ≤ 10,000 and 1 ≤ n ≤ 1000. Then the following m lines will give m donors names and
surnames and amount of donation. Every name and surname contains at most 12 characters. And
amountDonated can be floating point number between 0 and 10 6
Output specification
Show name surname and amountDonated of top n people in descending order.
http://acm.epoka.edu.al:8888/en/problem-pid-c643
Average of the Nth Student
Your Informatics professor heard that you did a nice program for your math professor. Now, he asks a
favor from you :) He keeps student grades in a file. Time to time, he wants to see student lists sorted
according to averages.
Question:
Write a program that reads n students information (name, surname and 4 marks). Then, your program will
calculate the floating point average of the students and then sort students according to the averages in
descending order. And, it will show the kth positioned student's name surname and average.
Input specification
The first line of the input contains two integers (n and k) where n denotes the number of students and k
denotes the position of the student to show in the output where 1 ≤ k ≤ n ≤ 2000. Each of the following n lines
will have semicolon separated information:
Name: At most 24 chars string containing only English letters and space.
Surname: At most 15 chars string containing only English letters.
4 Marks: 4 integer numbers between 0 and 100
Output specification
Show top kth student's name surname and average (with 2 decimal places after the floating point).
Sample Input I
6 2
Johnathan; Duncan; 47 91 95 47
Diane; Peterson; 45 46 66 82
Scott Allen; Bridges; 77 47 79 73
Clyde Eloise; Rios; 57 77 98 40
Homer; Conner; 89 99 52 84
Naomi; Taylor; 64 73 69 45
Sample Output I
Johnathan Duncan 70
1. Homer Conner 81
2. Johnathan Duncan 70
3. Scott Allen Bridges 69
4. Clyde Eloise Rios 68
5. Naomi Taylor 62.75
6. Diane Peterson 59.75
And thus, Johnathan Duncan has the second place with 70.
http://acm.epoka.edu.al:8888/en/problem-pid-c644
National Elections - 1
Question:
Write a program that reads n people information (name, surname, Personal Identification number (PIN)) from
two different regions. Then, your program will merge the two lists and sort people information according to
PINs in ascending order to produce one big list. Finally, the program will show the k th positioned person's
information from the sorted list.
Input specification
The input will have two sections.
The first line of the first region contains two integers (n and k) where n denotes the number of people and k
denotes the position of the person to show in the output. Each of the following n lines will have space
separated people information:
After the first list, there will be an integer number (m) and the following m lines will have people information
from the second region where 1 ≤ n ≤ 5,000; 1 ≤ m ≤ 5,000 and 1 ≤ k ≤ 10,000.
Output specification
Show kth person's information from the merged and sorted list. (positions start from 1)
Exercise 6
Averages with ECTS (The output must look EXACTLY the same as the sample, each operation must be done
using functions)
struct Person
{
char name[25];
char surname[20];
int age;
};
struct Student
{
struct Person theperson;
int grades[2];
};
struct Subject
{
char name[25];
int ects;
};