在VC6.0中怎么使用STL 需要怎么设置
我用vector 出现在很多错误
我用vector 出现在很多错误
解决方案 »
- 如何用代码创建一个ClistCtrl?
- 如何创建一个比较漂亮点的字体?
- 用iPicture怎样把图片另存为JPEG格式
- 谁有《Visual C++MFC编程实例》,《Visual C++MFC扩展编程实例》的源代码啊?100分相赠!
- 消息问题?mainfrm如何发消息给myfromview?在线等!解决送高分!
- 关于一个计算结果的问题
- 请问FTP上传文件的步骤是什么
- 命令解释器
- MFC 里面使用InvalidateRect的问题
- 老是看不懂 msdn 中的Framework 一词,谁能帮我形象地说明一下到底指的是什么?
- 怎么做的插件?
- 急:怎样杜绝原来的网站制作人员不能进入网站的后台?怎样知道网站制作人员在程序编写时留了后门?
假如上面语句。
// heapfunc.cpp
// compile with: /EHsc
//
// Functions:
// make_heap : convert a sequence to a heap
// sort_heap : sort a heap
// push_heap : insert an element in a heap
// pop_heap : remove the top element from a heap// disable warning C4786: symbol greater than 255 characters,
// okay to ignore
#pragma warning(disable: 4786)#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>using namespace std;int main()
{
const int VECTOR_SIZE = 8 ; // Define a template class vector of int
typedef vector<int > IntVector ; //Define an iterator for template class vector of strings
typedef IntVector::iterator IntVectorIt ; IntVector Numbers(VECTOR_SIZE) ; IntVectorIt it ; // Initialize vector Numbers
Numbers[0] = 4 ;
Numbers[1] = 10;
Numbers[2] = 70 ;
Numbers[3] = 10 ;
Numbers[4] = 30 ;
Numbers[5] = 69 ;
Numbers[6] = 96 ;
Numbers[7] = 100; // print content of Numbers
cout << "Numbers { " ;
for(it = Numbers.begin(); it != Numbers.end(); it++)
cout << *it << " " ;
cout << " }\n" << endl ; // convert Numbers into a heap
make_heap(Numbers.begin(), Numbers.end()) ; cout << "After calling make_heap\n" << endl ; // print content of Numbers
cout << "Numbers { " ;
for(it = Numbers.begin(); it != Numbers.end(); it++)
cout << *it << " " ;
cout << " }\n" << endl ; // sort the heapified sequence Numbers
sort_heap(Numbers.begin(), Numbers.end()) ; cout << "After calling sort_heap\n" << endl ; // print content of Numbers
cout << "Numbers { " ;
for(it = Numbers.begin(); it != Numbers.end(); it++)
cout << *it << " " ;
cout << " }\n" << endl ; //insert an element in the heap
Numbers.push_back(7) ;
push_heap(Numbers.begin(), Numbers.end()) ; // you need to call make_heap to re-assert the
// heap property
make_heap(Numbers.begin(), Numbers.end()) ; cout << "After calling push_heap and make_heap\n" << endl ; // print content of Numbers
cout << "Numbers { " ;
for(it = Numbers.begin(); it != Numbers.end(); it++)
cout << *it << " " ;
cout << " }\n" << endl ; // remove the root element from the heap Numbers
pop_heap(Numbers.begin(), Numbers.end()) ; cout << "After calling pop_heap\n" << endl ; // print content of Numbers
cout << "Numbers { " ;
for(it = Numbers.begin(); it != Numbers.end(); it++)
cout << *it << " " ;
cout << " }\n" << endl ;
}
Output
Numbers { 4 10 70 10 30 69 96 100 }After calling make_heapNumbers { 100 30 96 10 4 69 70 10 }After calling sort_heapNumbers { 4 10 10 30 69 70 96 100 }After calling push_heap and make_heapNumbers { 100 69 96 30 4 70 10 10 7 }After calling pop_heapNumbers { 96 69 70 30 4 7 10 10 100 }
Requirements
Header: <algorithm>
#include <vector>using namespace std;
出现了17个错误