STL
文章平均质量分 65
muximuxi525
有些事情暂时可以放下但是绝不能放弃
展开
-
HDU1022 Train Problem I
题目大意:水题一枚,但是自己很水,所以模拟了蛮久.囧.栈模拟.开了三个栈oo1,oo2,oo3.oo2保存要求火车离开的顺序oo3模拟火车进站的顺序oo1是辅助栈,为了方便提取进站的头一列车.学数据结构的时候没好好写写伪代码,所以模拟的思路一开始一塌糊涂.后来认认真真的写一遍伪代码,思路清晰多了:(1)如果oo3栈不为空,并且栈顶元素和oo2栈顶元素相等的话,那么两个栈都开原创 2013-03-16 11:35:59 · 919 阅读 · 1 评论 -
vector小结
#include#includeusing namespace std;typedef vector vec; int main(){//vector 的迭代器遍历和初始化 int kg[20]={1,2,3,4,5,6,7,8,9};vec aa(kg,kg+9);vec::iterator p;for(p=aa.begin();p!=aa.end();p++) cout原创 2012-10-18 20:23:15 · 622 阅读 · 0 评论 -
STL中的unique和erase
#include#include#include#includeusing namespace std;int main(){int n=17;int mm[30]={1,3,4,2,4,45,3,56,75,434,434,32,54,45,56,4353,32};//n=17; sort(mm,mm+n);int *p;p=unique(mm,mm+n);cout<<"原创 2012-10-18 11:38:30 · 757 阅读 · 0 评论 -
lower_bound && upper_bound 小结
iterator lower_bound( const key_type &key ); iterator upper_bound( const key_type &key ); iterator lower_bound( const key_type &key ): 返回一个迭代器,指向键值>= key的第一个元素。 iterator upper_bound( cons原创 2012-10-18 21:14:26 · 654 阅读 · 0 评论 -
POJ2002 第一次与map亲密接触
题目大意:呜呜~~我承认~~字符串的题目陷阱很多~~~Exactly seven of the characters in the string will be digits or letters~~说明给的每个串的里面有意义的字符是确切的7个,但是不排除有其余的字符。另外,scanf是无法输入string的 ,因为c++不能兼容C~~另外按个来的话,string是可以赋值给char的,但是整串是原创 2012-10-09 17:30:09 · 668 阅读 · 0 评论 -
POJ2643 Election(MAP)
题目大意:就是n对数据,上面一个是候选人姓名,下面一个是候选人党派,有个自由党也姑且当做一个特殊党派吧。然后m个数据是选票结果,求最后得胜者,得胜的要求是:其票数大于任何一个人。思路:这道水题需要注意几个地方:The word "tie" if there is no winner; that is, if no candidate receives more votes than every原创 2012-10-09 22:46:41 · 666 阅读 · 0 评论 -
全排列函数 next_permutation && prev-permutation
#include#include#includeusing namespace std;int main(){int a[10]={1,2,3};do{ cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl; }while(next_permutation(a,a+3));cout<<endl<<原创 2012-10-08 12:20:31 · 942 阅读 · 0 评论 -
sort qsort 小结
STL 中 sort 函数用法简介 做 ACM 题的时候,排序是一种经常要用到的操作。如果每次都自己写个冒泡之类的 O(n^2) 排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错。 STL 里面有个 sort 函数,可以直接对数组排序,复杂度为 n*log2(n) 。使用这个函数,需要包含头文件#include 。这个函数可以传两个参数或三个参数。第一个参数是要排序的区间原创 2012-08-20 19:54:40 · 545 阅读 · 0 评论