#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int>v;
int a;
while (cin >> a)
{
v.push_back(a);
}
int i = 0, j = v.size() - 1;
while (i <= j)
{
if (v[i] < v[j])
{
int temp = v[i];
cout << temp << endl;
while (v[i] == temp)
{
i++;
}
}
else if (v[i] > v[j])
{
int temp = v[j];
cout << temp << endl;
while (v[j] == temp)
{
j--;
}
}
else//相等的情况
{
int temp = v[i];
cout << temp << endl;
while (v[i] == temp)
{
i++;
}
while (v[j] == temp)
{
j--;
}
}
}
system("pause");
return 0;
}
山形数组按序不重复输出(双指针)
最新推荐文章于 2023-12-25 20:40:29 发布