Name: ____________________________________________________ Alpha: _____________ Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read today's lecture notes. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [20pts] Suppose we have the structs defined below, and variable V assigned and initialized as shown in the picture.
    
    struct Pos
    {
      int row, col;
    };
    struct Guy
    {
      char sym;
      Pos loc;
    };
    struct Group
    {
      Guy *peeps;
      int num;
    };
Write a statment(s) that:
  1. changes the value of col from 15 to 50:
  2. changes the sym $ to a %:
  3. swaps location 35,4 with location 21,44:
  4. Show, by annotating the above diagram, what would change if the following statement is executed:
    
    V[1].peeps = V[2].peeps;
    
  • [70pts] Write a program that reads in a file like smallscoredata.txt.
    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
    
    The data file contains player names and game-scores for players playing an online game.

    Note: The score data shows that a single person played the game multiple times. For example, Betty Smith played the game 4 times.

    Your program should print out the names, followed by the highest score acheived by that person. A run of on the small file would look like this:

    ~/$ ./hw
    Filename: smallscoredata.txt
    Betty Johnson 2400
    Andy Smith 800
    Betty Smith 2300
    As you see, the names have to be sorted by the last name (in alphabetical order) breaking the tie by the first name (in alphabetical order).

    Tips:

    Another example run with scoredata.txt:

    ~/$ ./hw
    Filename: scoredata.txt
    Andy Brown 2200
    Betty Brown 1900
    Casey Brown 1500
    Devon Brown 2400
    Andy Johnson 700
    Betty Johnson 2200
    Casey Johnson 800
    Devon Johnson 1600
    Andy Smith 1800
    Betty Smith 2100
    Casey Smith 900
    Devon Smith 2300
    Andy Williams 1800
    Betty Williams 1600
    Casey Williams 800
    Devon Williams 2200
    

    Submit to the submission server (due: 0800 on the next class day)

    ~/bin/submit -c=IC210 -p=hw29 hw.cpp
    

    Bring to class