书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

随笔分类 -  C STL

lower_bound的用法
摘要:lower_bound的headfile是algorithm.lower_bound的工作原理就是二分查找了。lower_bound的作用:lower_bound的返回值减去数组的地址就是要查找的元素在数组中的位置。即:Pos = lower_bound(a, a+10, 3)-a;那么Pos就是在数组a[10]中的位置了。下面给出它的具体用法并说明一些要注意的问题。View Code #include "iostream"#include "algorithm"using namespace std;int main(){ int a[4]={1, 2 阅读全文

posted @ 2012-03-21 22:13 More study needed. 阅读(900) 评论(0) 推荐(0) 编辑

map<int,int>和数组
摘要:我们知道,要是将数组开成int a[0xFFFFFFF]这么大,那是肯定不行。它会提示too big.但是如果用map的话,那就可以了。从这个方面来讲,map就是数组的升级版喽!这个可是我发现的哦。下面简单的给出一个例子来。题目:http://acm.swust.edu.cn/oj/problem/0822/下面给出错误的代码:View Code #include<iostream>#include<cstring>#include<algorithm>using namespace std;#define Max 1500000001int Num[Max 阅读全文

posted @ 2011-11-27 12:04 More study needed. 阅读(4278) 评论(0) 推荐(0) 编辑

vector的小小应用,大大功能
摘要:DescriptionAs a contestant, you must be familiar with the rules of ACM-ICPC. Teams are ranked according to the most problems solved. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed f 阅读全文

posted @ 2011-11-23 13:14 More study needed. 阅读(262) 评论(0) 推荐(0) 编辑

vector中的各种函数演示
摘要:1.初始化演示2.push_back()演示3.insert()演示4.pop_back()演示5.erase()演示6.size()演示7.empty()演示8.assign()演示#include<iostream>#include<vector>using namespace std;typedef vector<int> vint;int main(){ cout<<"初始化对象:"<<endl; vint vec1; ///vec1对象初始为空 vint vec2(10, 6); ///vec2对象最初有 阅读全文

posted @ 2011-11-23 10:24 More study needed. 阅读(249) 评论(0) 推荐(0) 编辑

vector的第四种初始化演示
摘要:#include<iostream>#include<vector>#include<cstring>using namespace std;int main(){ int arr[10] = {12,34,566,45,64,9,45,98,35,2}; char *str = "Hello vector!"; vector <int> vector1(arr, arr+10); vector <char> vector2(str, str+strlen(str)); cout<<"vect 阅读全文

posted @ 2011-11-23 10:11 More study needed. 阅读(226) 评论(0) 推荐(0) 编辑

再次相遇sort, 再次的感悟
摘要:以前本人曾经在CSDN上面发表过一篇关于sort的用法的文章。现在摘录如下:sort 函数是经常要用到的高级函数,用到好处,你会感觉你真的很棒!但是,第一个问题就是,你十分了解sort函数吗?其实不然。如果你就不彻底了解它,怎能用好呢?现在让我小露一手吧!我们可以自定义sort函数呢,当然,它要和结构体共同使用,那样更爽,它的这个功能主要用在多级排序上,方便死了。例如:struct student{ char name; int x, y, z;}stu[1000];bool check(strdent a, student b){ if(a.x > b.x)return true; i 阅读全文

posted @ 2011-10-21 10:36 More study needed. 阅读(436) 评论(0) 推荐(0) 编辑

Stack解决——括号匹配
摘要:Description题意描述: 在算术表达式中,除了加、减、乘、除等运算外,往往还有括号。包括有大括号{},中括号[],小括号(),尖括号<>等。 对于每一对括号,必须先左边括号,然后右边括号;如果有多个括号,则每种类型的左括号和右括号的个数必须相等;对于多重括号的情形,按运算规则,从外到内的括号嵌套顺序为:大括号->中括号->小括号->尖括号。例如,{[()]},{()},{{}}为一个合法的表达式,而([{}]),{([])},[{<>}]都是非法的。Input文件的第一行为一个整数n(1≤n≤100),接下来有n行仅由上述四类括号组成的括号表达 阅读全文

posted @ 2011-10-18 21:42 More study needed. 阅读(802) 评论(0) 推荐(0) 编辑

STL之map——解决POJ 2503
摘要:DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message 阅读全文

posted @ 2011-09-23 22:52 More study needed. 阅读(179) 评论(0) 推荐(0) 编辑

STL之stack——解决POJ 1028
摘要:DescributionStandard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. 阅读全文

posted @ 2011-09-23 22:45 More study needed. 阅读(214) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

点击右上角即可分享
微信分享提示