Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [10pts] Assume the following delcarations and fill in the table with either the type of the given expression, or "error" if appropriate.
    struct Point
      double x, y;
    struct Trial
      double stime, etime;
      Point *ways;
      int numways;
    struct Subject
      string name;
      int id;
      Trial pre, post;
    Subject S;
    Subject* A;
    int i, j;
    A.pre.ways[i][j] = A[i].pre;
    A[i].id = S.ways[i].y
  2. 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 47 to 50:
    2. changes the $ to a %:
    3. swaps location 35,4 with location 21,44:
  3. [90pts] The file hw.cpp contains a program that reads in a file defining "div boxes" (example files are hwin1.txt and hwin2.txt ), which for our purposes are colored rectangles that are supposed to appear in a webpage, and produces an a html file tst.html, which you can open in your browser as a local file (in your browser use ctrl-o to open a local file). It'll show the pretty rectangles. The program, however, is incomplete. The function
    void read(istream& in, DivBox &DB);
    needs a definition. All you have to do is add that definition! The only point here is that you have to deal with composed structs, i.e. structs containing structs containing structs. Here's the format you'll be reading in.
                  width  r  g b
                  |      |  | |
    new (20,100) 100x50 255,0,0 filled
         |   |       |            |
         x   y       height       aleternative is "hollow"
    Note: submit a printout of your .cpp file and a printout of the browser rendering of the tst.html produced by your program on the input file hwin2.txt.