✔ 最佳答案
Put the variables in an array. Write a function to check if any two variables are equal.
Samples codes are in C#. You can apply similar logic in C.
bool checkEqual(int[] A)
{
bool equal = false;
int len = A.Length - 1;
for (int j = 0; j < len; j++)
{
for (int i = j + 1; i < len; i++)
{
if (A[j] == A[i])
return true;
}
}
return equal;
}
void main()
{
int[] A = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
if (!checkEqual(A))
{
// your codes here
}
}