CPSC 212
(Data Structures and Algorithms)
Assignment 1
- Objectives:
- To create a simple C++ 2D point class, implement STL sort, average.
- Due date:
- 09/05/06
- What to hand in:
- Code "tarball" (e.g.,
asg1.tar.gz
) including:
README
file containing assignment and solution
descriptions, e.g., program design, description of algorithm,
etc., if appropriate.
INSTALL
file containing any specific compliation
quirks peculiar to your program, e.g.,
Compilation: make -f Makefile.tniop
.
USAGE
file containing any specific usage quirks
peculiar to your program, e.g.,
Usage: ./tniop < points.in
where
./tniop
is the executable and
points.in
is the input.
src/
directory with source code.
- Description:
- Implement a 2D Point class, with functionality suggested
in the
point.h interface.
(You are free to rewrite the class interface and
declare your own Point class, so long as it satisfies
the required funcionality requirements.)
- Your class must be able to handle I/O and object comparison
via functors, as suggested in the
tniop.cpp driver.
- Provide code in the driver to compute the centroid of the
found in the
points.in input file.
- Sample output (sans centroid) can be found here:
points.out.
- (Bonus) Write the centroid code ``on the fly'', i.e.,
in one loop instead of one summation loop followed
by division by n
Hint: the math for this is:
mi = (i/(i+1)) mi +
(1/(i+1)) xi