//The author is Gao_Xiong
//All rights reserved
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int lo = 2, hi = 7;
int e = 3;
vector<int>V(8, 0);
for (int i = 0; i < 8; i++)
{
V[i] = i;
cout << V[i] << " ";
}
cout << endl;
while ((lo < hi--) && e != V[hi])//此处hi先与lo作比较,然后hi再减一,减一后的hi赋给后面e!=V[hi]中的hi
{
cout << hi << " ";
}
cout << endl;
cout << hi << endl;
system("pause");
return 0;
}
运行结果:
0 1 2 3 4 5 6 7
6 5 4
3
请按任意键继续. . .
上述代码讲述了位于while条件中hi的变化,hi先与lo作比较,然后hi再减一,减一后的hi赋给后面e!=V[hi]中的hi。