I posted a challenge on a different BBS that asked for a program that checks to see if a set of 4 ordered pairs create a function on a graph or not (no x value is the same as another). I have created the program and it works fine, but I need to add one more thing to it. I need it to check to see if the ordered pairs are the same (in which if they were, they wouldn't stop it from creating a function). What I have so far is-
I have thought of just doing like I did for the x values and assign them a letter of the alphabet and check it like that, but that seems a little unnessicary. What could I do to check to see if the ordered pairs were the same as another? Could I just assign the ordered pairs to different variables, remove the comma, and comapre them to each other?
using namespace std;
int IsFunction(char OrderedPairs);
cout << "Enter ordered pairs: ";
function = IsFunction(OrderedPairs);
if (function == 1)
cout << "Is not a function.";
cout << "Is a function.";
int IsFunction(char OrderedPairs)
int a = OrderedPairs;
int b = OrderedPairs;
int c = OrderedPairs;
int d = OrderedPairs;
if (a == b || a == c || a == d)
else if (b == c || b == d)
else if (c == d)
Oh, and if you need to know, the program will be given ordered pairs like this-
So I will not need to remove spaces. I will probley add some error checking when I get this part done.
Enter ordered pairs: (1,2)(3,4)(5,6)(7,8)
The challenge is mine (I posted it for others to try) but I am just needing help with my own solution. I will not post any code y'all may supply for an example or a solution unless you give me permission, and even then you will get create for helping me out.