Arrays of structs
Read · 1 of 3
A table in memory
Student class[60]; is 60 student records. class[i].marks is the marks of the i-th student.
Sorting works as with ints, but you compare a field and swap whole structs (a struct assignment copies every field).
Read this lesson as text
A class of students: read them, search them, and sort them.
A table in memory
Student class[60]; is 60 student records. class[i].marks is the marks of the i-th student.
Sorting works as with ints, but you compare a field and swap whole structs (a struct assignment copies every field).
Exercise: Class topper
Read n (1 to 60), then n lines of name marks. Print the name and marks of the topper; if two tie, the one listed first.
Exercise: Rank list
Read n (1 to 60) students as name marks. Print them sorted by marks, highest first; equal marks in alphabetical order of name. One name marks per line.