C++ STL——heap相关算法
#include "stdafx.h"
#include <iostream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <math.h>
using namespace std;
int main(int argc, char* argv[])
{
int a[5]={0,1,2,3,4};
make_heap(a,a+4,less<int>());
cout<<"make_heap:";
copy(a,a+5,ostream_iterator<int>(cout," "));
pop_heap(a,a+4);
cout<<"\n"<<"pop_heap:";
copy(a,a+4,ostream_iterator<int>(cout," "));
a[4]=6;
push_heap(a,a+4);
cout<<"\n"<<"push_heap:";
copy(a,a+5,ostream_iterator<int>(cout," "));
sort_heap(a,a+4,less<int>());
cout<<"\n"<<"sort_heap:";
copy(a,a+5,ostream_iterator<int>(cout," "));
return 0;
}
在vs2010上编译,怎么是a+4;不是开闭区间吗;
lazy delete;