1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include <iostream>
#include <limits>
#define ARGUMENTS v_01, v_02, v_03, v_04, v_05, v_06, v_07, v_08, v_09, v_10, v_11, v_12, v_13, v_14, v_15
bool is_unique (int &being_checked, int &v_01, int &v_02, int &v_03, int &v_04, int &v_05,
int &v_06, int &v_07, int &v_08, int &v_09, int &v_10,
int &v_11, int &v_12, int &v_13, int &v_14, int &v_15
)
{
// Save the value
int i = being_checked;
// The value is currently being checked
being_checked = std::numeric_limits<int>::min();
bool unique = true;
if(false) unique = unique;
else if(i == v_01) unique = false;
else if(i == v_02) unique = false;
else if(i == v_03) unique = false;
else if(i == v_04) unique = false;
else if(i == v_05) unique = false;
else if(i == v_06) unique = false;
else if(i == v_07) unique = false;
else if(i == v_08) unique = false;
else if(i == v_09) unique = false;
else if(i == v_10) unique = false;
else if(i == v_11) unique = false;
else if(i == v_12) unique = false;
else if(i == v_13) unique = false;
else if(i == v_14) unique = false;
else if(i == v_15) unique = false;
// Restore the original value when done
being_checked = i;
return unique;
};
int main()
{
int v_01, v_02, v_03, v_04, v_05, v_06, v_07, v_08, v_09, v_10, v_11, v_12, v_13, v_14, v_15;
std::cout << "Enter 15 values : " << std::endl;
if(true)
{
v_01 = 11; std::cout << v_01 << std::endl;
v_02 = 22; std::cout << v_02 << std::endl;
v_03 = 35; std::cout << v_03 << std::endl;
v_04 = 44; std::cout << v_04 << std::endl;
v_05 = 52; std::cout << v_05 << std::endl;
v_06 = 63; std::cout << v_06 << std::endl;
v_07 = 74; std::cout << v_07 << std::endl;
v_08 = 81; std::cout << v_08 << std::endl;
v_09 = 94; std::cout << v_09 << std::endl;
v_10 = 105; std::cout << v_10 << std::endl;
v_11 = 112; std::cout << v_11 << std::endl;
v_12 = 121; std::cout << v_12 << std::endl;
v_13 = 135; std::cout << v_13 << std::endl;
v_14 = 142; std::cout << v_14 << std::endl;
v_15 = 151; std::cout << v_15 << std::endl;
}
else
{
std::cin >> v_01;
std::cin >> v_02;
std::cin >> v_03;
std::cin >> v_04;
std::cin >> v_05;
std::cin >> v_06;
std::cin >> v_07;
std::cin >> v_08;
std::cin >> v_09;
std::cin >> v_10;
std::cin >> v_11;
std::cin >> v_12;
std::cin >> v_13;
std::cin >> v_14;
std::cin >> v_15;
}
bool unique(is_unique(v_01, ARGUMENTS));
unique = unique && is_unique(v_02, ARGUMENTS);
unique = unique && is_unique(v_03, ARGUMENTS);
unique = unique && is_unique(v_04, ARGUMENTS);
unique = unique && is_unique(v_05, ARGUMENTS);
unique = unique && is_unique(v_06, ARGUMENTS);
unique = unique && is_unique(v_07, ARGUMENTS);
unique = unique && is_unique(v_08, ARGUMENTS);
unique = unique && is_unique(v_09, ARGUMENTS);
unique = unique && is_unique(v_10, ARGUMENTS);
unique = unique && is_unique(v_11, ARGUMENTS);
unique = unique && is_unique(v_12, ARGUMENTS);
unique = unique && is_unique(v_13, ARGUMENTS);
unique = unique && is_unique(v_14, ARGUMENTS);
unique = unique && is_unique(v_15, ARGUMENTS);
if(unique)
{
std::cout << "15 values are unique" << std::endl;
}
else
{
std::cout << "15 values are NOT unique" << std::endl;
}
return 0;
}
|