1. ## Graph functions check

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-
Code:
```#include <iostream>
using namespace std;

int IsFunction(char OrderedPairs[20]);

int main()
{
char OrderedPairs[20];
int function;
cout << "Enter ordered pairs: ";
cin.getline(OrderedPairs, 20);
function = IsFunction(OrderedPairs);
if (function == 1)
cout << "Is not a function.";
else
cout << "Is a function.";
return 0;
}

int IsFunction(char OrderedPairs[20])
{
int a = OrderedPairs[1];
int b = OrderedPairs[6];
int c = OrderedPairs[11];
int d = OrderedPairs[16];
if (a == b || a == c || a == d)
return 1;
else if (b == c || b == d)
return 1;
else if (c == d)
return 1;
else
return 0;
}```
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?

Oh, and if you need to know, the program will be given ordered pairs like this-
Enter ordered pairs: (1,2)(3,4)(5,6)(7,8)
So I will not need to remove spaces. I will probley add some error checking when I get this part done.

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.

Thanks.

2. Couldn't you just assign the y values to the variables e,f,g and h the same way you do the x values? Then all you would need would be to write the if statements like this:
Code:
```	if ((a == b && e!=f) || (a==c && e!=g) || (a==d && e!=h))
return 1;
etc...```
I'm sure theres a more elegant solution, but this is closest to what you have already. Keep in mind though you are assigning chars to ints. If you want to use ints, you need to subtract '0' from each number. Also, this solution will not work for double digit or negative numbers, you'll need to parse those if they are allowable.

3. 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
Yea I have considered that. But I was wondering about other solutions. Thanks anyways though.

4. I decided to use that method for the time being, until someone gives a better idea. Here is my code right now.
Code:
```#include <iostream>
using namespace std;

int IsFunction(char OrderedPairs[20]);

int main()
{
char OrderedPairs[20];
int function;
cout << "Enter ordered pairs: ";
cin.getline(OrderedPairs, 20);
function = IsFunction(OrderedPairs);
if (function == 1)
cout << "Is not a function.";
else
cout << "Is a function.";
return 0;
}

int IsFunction(char OrderedPairs[20])
{
int ax = OrderedPairs[1];
int ay = OrderedPairs[3];
int bx = OrderedPairs[6];
int by = OrderedPairs[8];
int cx = OrderedPairs[11];
int cy = OrderedPairs[13];
int dx = OrderedPairs[16];
int dy = OrderedPairs[18];
if ((ax == bx && ay != by) || (ax == cx && ay != cy) || (ax == dx && ay != dy))
return 1;
else if ((bx == cx && by != cy) || (bx == dx && by != dy))
return 1;
else if (cx == dx && cy != dy)
return 1;
else
return 0;
}```