CMIS 140
Due: 30 Nov
Write a program that maintains sets of integers.
A set is a collection of objects; here the objects will be integers.
Objects can be added to a set and removed from a set. Objects in a
set are called members of that set. Members of a set are unique, ie.
there are no duplicates in a set.
As an example of a set (whose members are integers):
{3, 54, -2, 0} this set has four members.
(Curly braces are commonly used in math to indicate a set.)
{3, 54, 3} is not a set because the members are not unique.
Sets have many uses, one of which is an excuse for a wonderful
programming assignment.
How to represent a set of integers in C? An array of integers will
work quite nicely (this implies that there will be some maximum size
that a set can be). We'll have two sets in the program; call them 0
and 1. These will be two arrays of int.
Allow the user of the program to: (this will be the main menu)
1. add a member to one of the sets
2. display the members of a set
3. ask whether a particular integer is a member of a particular set
4. display the intersection of the two sets (the intersection
of two sets are the members they have in common)
5. display the union of the two sets (the union of two sets
are the members that are in either or both of the sets)
6. quit the program
Extra credit: delete a member from a set
Download and experiment with the
setsDOS.exe or
setsLinux.exe
so that you understand what your program is supposed to do.