CHAPTER5-13.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER5-13.cpp
- #include <iostream>
- #include <queue>
- #include <assert.h>
- using namespace std;
- int main()
- {
- priority_queue<int> Q;
- Q.push(1);
- Q.push(4);
- Q.push(2);
- Q.push(8);
- Q.push(5);
- Q.push(7);
- assert(Q.size() == 6);
- assert(Q.top() == 8);
- cout<<Q.top();
- Q.pop();
- assert(Q.top() == 7);
- cout<<Q.top();
- Q.pop();
- assert(Q.top() == 5);
- cout<<Q.top();
- Q.pop();
- assert(Q.top() == 4);
- cout<<Q.top();
- Q.pop();
- assert(Q.top() == 2);
- cout<<Q.top();
- Q.pop();
- assert(Q.top() == 1);
- cout<<Q.top();
- Q.pop();
- assert(Q.empty());
- return 0;
- }