zf*****@umd.umich.edu wrote:
Create a computer program to classify Functions.
The input to this program is two relations R1 and R2, both from a set
A to a set B. Each of these relations should be input into the program
as a set of ordered pairs (a, b) where a ? A ? Z, the integers, and b
? B ? Z. The sets A and B must be specified. Although not all the
possible values of the domain of the functions need to be considered,
it is expected that the number of domain values considered in the
inputs is sufficient to characterize the function or relation in
question.
The program must list the ordered pairs input for each relation,
indicating the relation to which each of them belong.
Can anyone help with this?
a) For homework help, the most important rule here is: you have to show your
efforts first.
b) The above problem does not really make any sense. The input-output
behavior of the program is not clearly specified. As far as I can tell,
just copying the input straight to the output would be an acceptable
solution, although I doubt that this is indented. Also, it is not clear
what the statement "Although not all the possible values of the domain of
the functions need to be considered,it is expected that the number of
domain values considered in the inputs is sufficient to characterize the
function or relation in question" is supposed mean: a relation is
characterized by all and only by all of the pairs that form it. The same
holds for a function.
c) Unless you have a specific C++ question, your post is off-topic here. See
the FAQ for what goes here and where to post questions that do not belong
here.
d) As for general advice about how to represent functions and relations in
C++, read up on std::map<and std::multimap<>.
Best
Kai-Uwe Bux