CS202 Computer Science II
Assignment 0
Due Sept 2 before 9:00 a.m. in class
Last modified 8/23/98 @ 1:00 p.m..
Objectives: Learn about the Tompson lab environment,
editing, compiling, and running programs under Unix-like operating
systems. You will also learn about functional abstraction, modules,
and separate compilation of program files. This is a difficult first
assignment and due in one week. Start now!
Files needed: as0.cpp. Save files by clicking
the right mouse button and using the "save link as" option in
netscape. (This is especially useful for binary files not
designed to be displayed in your browser).
Turnin Instructions.
Solution:Assignment 0's solution. If you
can access the solution it is too late to hand in the assignment.
Problem:
You need to complete the program contained in as0.cpp. I have provided a sorting function that
expects an array of integers, and the size of the array; the function
sorts the array. You need to write the function ReadArray,
the function WriteArray that read in an array and print out
an array respectively, and the function Swap that swaps two
integers. You only need to handle Integers.
Compiling and Running
I have also supplied a makefile to help
manage program files. It assumes you will put your code in a file
named as0.cpp and will produce an executable named as0. Make
sure as0.cpp and makefile are in the same
directory. If the makefile does not work properly simply use:
% g++ -o as0 as0.cpp
% as0
to compile and run the program.
Now you just need to type make at the unix
prompt. The make command
will compile, and link your source files and make an executable named
as0.
Here's an example of compiling and running a correct and complete as0.
% is the unix prompt.
% make
g++ -c as0.cpp
g++ -o as0 as0.o
% as0
This program sorts up to 100 input integers.
Use end-of-file to terminate the list early.
Begin input:
9
67
45
0
49
3478
173
4384
Sorted list:
0
9
45
49
67
173
3478
4384
%
Constraints and Hints
- <ctrl>-d (pressing the control key and the "d" key
simultaneously) denotes end of input (end of file) in unix.
- The maximum number of items that you can work with is 100
Turnin Instructions.
Sample I/O for testing was provided will be available on the
TA's page.
Talk to me if you have questions