// test02.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
void FindNumsAppearOnce(vector<int> data, int* num1, int *num2) {
int flag = 0;
int a = 0;
int num1flag = 0;
for (int i = 0;i < data.size();i++)
{
flag = 0;
for (int j = 0;j < data.size();j++)//注意,此时的i不能等于j.注意j的下表,从1开始,而不是从i+1开始
{
if (i == j) continue;
if (data[i] == data[j])
{
// cout << data[i] << endl;
flag = 1;
// break;
}
}
if (flag == 0 && num1flag==0 )
{
*num1 = data[i];
// cout << data[i] << endl;
num1flag=1;
flag = 1;
}
if (flag == 0 && num1flag == 1)
{
*num2 = data[i];
// cout << data[i] << endl;
}
}
//cout << "num1:" << *num1 << endl;
//cout << "num2:" << *num2 << endl;
}
};
int main()
{
vector<int> vec = {1,2,3,4,5,6,7,7,6,5,1,2};
Solution so;
int i = 0, j = 0;
int *num1=&i;
int *num2=&j;
so.FindNumsAppearOnce(vec, num1, num2);
cout << endl;
return 0;
}