#include <stdio.h> #include <stdlib.h>int find_f (int arr[], int len) //looking for individual number { int i, j, k; for (i = 0; i < len; i++) { k = 0; for (j = 0; j < len; j++) { if ((Arr[i] & arr[j]) == Arr[i]) //If the two numbers are the same,k++ k++; } if (k == 1) return (i); // if (k=1), which is the only one in this array, returns the subscript } return (len + 1) of this number;} Int main () { int arr[] = { 4, 6, 4, 5, 5, 3, 6 }; //array initialization, freely assignable int len = sizeof (arr) / sizeof (arr[0]),c; //array length c = find_f (arr, len); / /function call if (C > len) //determines whether the return value is legitimate printf ("there is no separate number in this set of numbers \ n"); else printf ("%d\n", Arr[c]); //is legally the output of a separate number system ("pause"); return 0;}
This article is only in the learning process of their own ideas, can only achieve simple functions, may not consider the optimization of the program, and the code written by the great God there is a certain gap, if the great God found the problem, please enlighten me, if you have a better way, may wish to share, thank you!
This article is from the "Sharing Progress" blog, be sure to keep this source http://xmwen1.blog.51cto.com/10730069/1706070
Only one number appears once in a set of data. All other numbers appear in pairs. Please find out the number.