Find the highest grade | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Find the highest grade

Input: First line contains n(0 < n < 1001). Then n lines inputed in given format: First number - student's ID Second element - student's name(not more that 100) Third number - the final grade of the student Output: n lines sorted by grades(Note:If two students have same grades your have to sort them by ID) Samples: INPUT OUTPUT 3 2 Zuckerberg 99.1 1 Ivano 51 2 Zuckerberg 99.1 3 Mendelson 99.0 How to solve it? This is my code: https://code.sololearn.com/cm9Vp6qZK2CW/#cpp

27th Oct 2020, 12:48 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
7 Answers
0
printing top value : void out(Student* s, int n) { Student* it = s; cout << it->ID << " " << it->surname << " " << it->grade << endl; } }
27th Oct 2020, 4:11 PM
Jayakrishna 🇮🇳
+ 1
if ((s + j)->grade < s[j + 1].grade) Just Use < instead of >
27th Oct 2020, 1:34 PM
Jayakrishna 🇮🇳
0
What do you mean?
27th Oct 2020, 2:11 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
0
I mean in line number 37 : make that change Edit : Azat Malgazhdar This if ((s + j)->grade < s[j + 1].grade)
27th Oct 2020, 4:00 PM
Jayakrishna 🇮🇳
0
I need only one answer in this code Id_surname_grade who has highest one
27th Oct 2020, 4:06 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
0
Thank you!
27th Oct 2020, 4:12 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
0
You're welcome...
27th Oct 2020, 4:14 PM
Jayakrishna 🇮🇳