Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
struct GameRec
{
string first, last;
int score;
};
struct Point
{
double x, y;
};
int i,j;
double w;
Point P;
GameRec G;
GameRec *A;
Point* B;
| expression | type |
G | |
B | |
A.first | |
A[i] | |
A.first[i] | |
A[i].first | |
w + A[j].score | |
B[i] | |
P.x++ | |
G.score = w |
| declarations | function calls |
struct Grades
{
double* A;
int N;
string name;
};
Grades* A; |
sort(A,10); int k = search(A[0].A,20,75.5); |
~/$ ./prog smallscoredata.txt Betty Johnson 2400 Andy Smith 800 Betty Smith 2300I have two pieces of advice. First, look at the "Heterogeneous Data" section of the lecture notes! Second, I would sort the data first as shown below, and then run through the sorted data in order to pull out each individual's highest score. In fact, if you just get the sorting done right, you'll get most of the credit.
| smallscoredata.txt | sorted the "right way" |
10 Betty Smith 900 Betty Johnson 1600 Betty Johnson 2400 Andy Smith 800 Betty Smith 1200 Betty Smith 2200 Betty Johnson 1600 Andy Smith 200 Betty Smith 2300 Betty Johnson 1900 |
Betty Johnson 2400 Betty Johnson 1900 Betty Johnson 1600 Betty Johnson 1600 Andy Smith 800 Andy Smith 200 Betty Smith 2300 Betty Smith 2200 Betty Smith 1200 Betty Smith 900 |