0% found this document useful (0 votes)
12 views5 pages

Lab - 6 Structures

The document describes a program that reads voter registration information from two regions, merges the lists, sorts them by personal identification number, and outputs the voter information at a given position k.

Uploaded by

lina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Lab - 6 Structures

The document describes a program that reads voter registration information from two regions, merges the lists, sorts them by personal identification number, and outputs the voter information at a given position k.

Uploaded by

lina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

The Highest Average

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.

Sample Input: Sample Output:


5 Alban Mehmeti 85.5
Arben Hoxha 76 50 70 80 80 -1
Artur Dardani 100 100 -1
Klevis Shehu 100 100 100 -1
Alban Mehmeti 90 90 80 82 -1
Ervin Murataj 70 70 60 70 70 80 -1

Output Explanation :

Student list according to their averages

Arben Hoxha 71.2


Artur Dardani 50.0
Klevis Shehu 75.0
Alban Mehmeti 85.5
Ervin Murataj 70.0
According to these results, Alban Mehmeti has the highest average in the class.
http://acm.epoka.edu.al:8888/en/problem-pid-c62d

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).

Sample Input I Sample Output I


6 3 Erma Gomez 78.75
Erma Gomez 89 81 76 69 Barbara Bennett 75.5
Geraldine Craig 40 69 73 49 Carmen Horton 74.5
Margie Reid 44 55 63 63
Barbara Bennett 96 54 75 77
Christopher Hampton 48 72 59 87
Carmen Horton 56 68 90 84

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.

Sample Input I Sample Input II


6 4 10 5
Erma Gomez 85 Archie Cortez 366.8
Christopher Hampton 352 Carla Caldwell 1664.5
Geraldine Craig 335 Don Townsend 4435
Barbara Bennett 8 Drew Stewart 3520
Carmen Horton 375.5 Emanuel Hines 3262
Margie Reid 405 Lloyd Parks 5965
Marcia Phillips 2327
Oliver Burgess 748
Robin Collins 774
Rosemary Rice 4240.7
Sample Output I Sample Output II
Margie Reid 405 Lloyd Parks 5965
Carmen Horton 375.5 Don Townsend 4435
Christopher Hampton 352 Rosemary Rice 4240.7
Geraldine Craig 335 Drew Stewart 3520
Emanuel Hines 3262

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

Output Explanation: Here is the list sorted in descending order:

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

Every fourth year,


national elections are held
throughout the country.
After voting, people sign
the register notebook.
And then, to prevent
multiple votes, their right
hand index finger is dyed
with an indelible ink.
This year government wants to change the system to computerized system. After voting the people will be
registered to the computer. For this purpose, the lists from different regions are collected in the city center.
And full sorted list is going to be prepared for the database.

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 list from the first region


 The list from the second region

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:

 Name: At most 12 chars string containing only English letters.


 Surname: At most 12 chars string containing only English letters.
 PIN: 9 digit integer number

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)

Sample Input I Sample Output I


6 3 Viola Johnston 231606490
Rodrigo Chilton 495008016
Despina Roark 431711128
Vashti Sutton 358575755
Kathy Valencia 111493853
Byron Miller 805827373
Rodrigo Kinney 436512022
5
Shamika Cone 197767850
Felix Regalado 606171045
Stuart Pitre 772541445
Viola Johnston 231606490
Marcy Fusco 393310572

Output Explanation: Here is the list sorted in ascending order:


Kathy Valencia 111493853
Shamika Cone 197767850
Viola Johnston 231606490
Vashti Sutton 358575755
Marcy Fusco 393310572
Despina Roark 431711128
Rodrigo Kinney 436512022
Rodrigo Chilton 495008016
Felix Regalado 606171045
Stuart Pitre 772541445
Byron Miller 805827373
And thus, Viola Johnston is in the 3rd position in the merged and sorted list.
http://acm.epoka.edu.al:8888/en/problem-pid-c645

Exercise 6

Averages with ECTS (The output must look EXACTLY the same as the sample, each operation must be done
using functions)

The STRUCTURES you should use:

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;
};

OUTPUT should look like this:


https://drive.google.com/file/d/1BG6DJyiDKImEd7W0-VLI-EsP7ARcFMef/view?
usp=sharing

Average should be calucated as


[(grade1*credit1)+(grade2*credit2)]/(credit1+credit2)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy