//010E
#include "stdio.h"
#include "stdlib.h"
int find_repeat_number(int arr[], int n)
{
int ret = -1;
if (n > 1){
char* flagArr = (char*)malloc(sizeof(char)* n);
for (int i = n; i--; flagArr[i] = 0);
for (int i = 0; i<n; ++i){
int number = arr[i];
if (flagArr[number]){
ret = number;
break;
}
flagArr[number] = 1;
}
free(flagArr);
}
return ret;
}
int _tmain(int argc, _TCHAR* argv[])
{
int nums[] = { 7, 9, 8, 5, 2, 5, 6, 1, 3, 2 };
int count = sizeof(nums) / sizeof(nums[0]);
printf("数组 = ");
for (int i = 0; i < count; printf("%d,", nums[i++]));
printf("\n");
int result = find_repeat_number(nums, count);
if (result >= 0)
printf("重复的数字:%d\n", result);
else
printf("没有重复数字\n");
return 0;
}