int main() { int i; int lotsOfInts[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int myApples = 10; int yourApples = 5; int ourApples = myApples + yourApples; double myFloat = ourApples / yourApples; intComp(myApples, yourApples, ourApples); floatIntComp(myApples, myFloat); // The individual elements of the array should not be comparable to // one another: intNonComp(lotsOfInts[0], lotsOfInts[1], lotsOfInts[2]); intNonComp(lotsOfInts[3], lotsOfInts[4], lotsOfInts[5]); intNonComp(lotsOfInts[6], lotsOfInts[7], lotsOfInts[8]); intNonComp(lotsOfInts[9], lotsOfInts[10], lotsOfInts[11]); // These become comparable due to interaction INSIDE the function float x = 0.234, y = 0.432, z = 0.101, w; w = floatCompInternal(x, y, z); int a = 1, b = 2 , c = 3, d; d = intCompInternal(a, b, c); // Grab new values for myApples, yourApples, and ourApples and pass // them into intNonComp. These new values are non-comparable so // that intNonComp's params are still not comparable. myApples = 100; yourApples = 200; ourApples = 300; intNonComp(myApples, yourApples, ourApples); // Ditto for floats: x = 1.234; y = 2.345; z = 3.456; floatNonComp(x, y, z); floatNonComp((float)lotsOfInts[0], (float)lotsOfInts[1], (float)lotsOfInts[2]); floatNonComp((float)lotsOfInts[3], (float)lotsOfInts[4], (float)lotsOfInts[5]); floatNonComp((float)lotsOfInts[6], (float)lotsOfInts[7], (float)lotsOfInts[8]); // Now let's test some stuff which becomes comparable due to // interactions which occur AFTER the function call: // (This is where the extra round of propagations at the end is crucial) // Re-assign fresh new values: a = 1; b = 2; c = 3; intCompAfter(a, b, c); x = 0.1; y = 0.2; z = 0.3; floatCompAfter(x, y, z); // Now let's have the params interact d = a / b * c; w = x - (y + z); return 0; }
bool intEquals(const void *int1, const void *int2) { return intComp(int1, int2) == 0; }