elearningkctcsedu In a Word document complete the following
Solution
a. main() {
input(teachers[30]);
input(noOfBooks[30]);
sort(noOfBooks);
print(\"4 teachers whose classroom donated the most books\");
print(teachers[0]);
print(teachers[1]);
print(teachers[2]);
print(teachers[3]);
}
sort(noOfBooks) {
for (i = 0; i < 30; i++) {
for (j = 0; j < 29; j++) {
if (noOfBooks[j] < noOfBooks[j+1]) {
swap(noOfBooks[j], noOfBooks[j+1]);
swap(teaches[j], teachers[j+1]);
}
}
}
}
b. main() {
input(teachers[30]);
input(noOfBooks[30]);
input(noOfStudents[30]);
bookRatios[30];
for (i = 0; i < 30; i++)
bookRatios[i] = noOfBooks[i] / noOfStudents[i];
sort(bookRatios);
print(\"4 teachers whose classroom donated the most books\");
print(teachers[0]);
print(teachers[1]);
print(teachers[2]);
print(teachers[3]);
}
sort(bookRatios) {
for (i = 0; i < 30; i++) {
for (j = 0; j < 29; j++) {
if (bookRatios[j] < bookRatios[j+1]) {
swap(bookRatios[j], bookRatios[j+1]);
swap(teaches[j], teachers[j+1]);
}
}
}
}
