Two digits in a string appear only once, and the rest are in pairs.
Of course, if the problem is that there is only one different number, and other numbers are the same in pairs, then all numbers are exclusive or this number is obtained.
This time there are two numbers that appear only once, and the other numbers are the same
1) First, all numbers are different or the number t is obtained.
2) Calculate the position flag of the first 1 of the binary t.
3) divide all numbers into two groups (b1 [], b2 []) based on whether the binary flag position is 1 (the number of each group must be an odd number)
4) Group b1 and obtain ans1. group b2 and obtain ans2.
# Include
# Include
Using namespace std; # define isset (a, n) a & (1 <(n) # define N 1000int main () {int t, c, I, B [N], b1 [N], b2 [N], flag, cou1, cou2, ans1, ans2; while (cin> c, c) {if (c % 2! = 0) {cout <"c must be an even number" <
> B [0]; t = B [0]; for (I = 1; I
> B [I]; t ^ = B [I];} flag = 0; for (I = 0; I <32; I ++) if (isset (t, i) {flag = I; break;} cou1 = cou2 = 0; for (int I = 0; I