C++新手问题
「已注销」 2017-04-19 12:56:10 #include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> ve;
int n,i;
for(int i=0; i<10; i++)
{
cin>>n;
ve.push_back(n);
}
vector <int> ::iterator a,b,c,m;
for(i = 1; i<ve.size(); i++)
{
a = ve.begin();//begin
b = ve.begin()+i-1;//end
int temp = ve.at(i);
while(a<=b)
{
m = ve.begin()+((b-a)/2);
if(*m > temp)
{m--;
b = m;
}
else if(*m <= temp)
{m++;
a = m;
}
}
for(int j = i-1; j>(b-a); j--)
{
ve.at(j+1) = ve.at(j);
}
*(b+1) = temp;
}
}
//2 4 3 5 4 6 5 7 6 4
大神们
这个代码是二分法排序
不知道为什么执行到while循环就出不去了
调试发现a b m的值一直没有变
求指导 谢谢各位大神了