class Solution {
public:
void FindNumsAppearOnce(vector<int> data,int* num1,int *num2) {
int flag = 1;
int number = 0;
int length = data.size();
vector <int> ivec;
for (int i = 0; i !=length ; i++)
{
for( int j = 0; j!=length ;j++)
{
if (i==j)
continue;
if( data[i] == data[j])
{
flag = 0;
}
}
if ( flag == 1 && number ==0)
{
*num1 = data[i];
flag = 0;
number = 1;
}
if (flag == 1 && number ==1)
{
*num2 = data[i];
break;
}
flag = 1;
}
}
};
剑指offer数组中只出现一次的数字
最新推荐文章于 2024-11-02 14:41:43 发布