
---------STL---------
Ruanran
学习
展开
-
istringstream用法详解 (HDU 1106 排序 STL写法)
istringstream的用途:将字符串以空格为分隔符分割具体实现:#include <iostream>#include <sstream>//istringstream需要的头文件 using namespace std;int main(){ string s,ss;//s是输入的字符串 ss用来存放分隔出的字符串 while(getline(cin...原创 2018-04-24 16:06:28 · 608 阅读 · 0 评论 -
(STL—map用法)HDU 1029 Ignatius and the Princess IV
map默认按键值由小到大排序,并且过滤掉重复输入的键值,与set容器相似,不同的是map多了一个映照键值和映照数据可以自定义类型如上例子的具体实现:#include <map> #include <string> #include <iostream> using namespace std; int main(int argc, char* argv[...原创 2018-04-24 16:31:20 · 148 阅读 · 0 评论 -
(STL—s.replace()和s.find())NYOJ 113 字符串替换
字符串替换时间限制:3000 ms | 内存限制:65535 KB难度:2描述编写一个程序实现将字符串中的所有"you"替换成"we"输入输入包含多行数据 每行数据是一个字符串,长度不超过1000 数据以EOF结束输出对于输入的每一行,输出替换后的字符串样例输入you are what you do样例输出we are what we doAC代码:/*//从字符串s 下标5开始,查找字符串b...原创 2018-04-24 21:04:19 · 1827 阅读 · 0 评论 -
(s.substr(pos,n)功能+next_permutation(,)和prev_permutation(,)简单用法)NYOJ 19 擅长排列的小明
1.s.substr(pos,n)功能:从一个字符串复制一个从指定位置pos开始,并具有指定长度n的子字符串2.next_permutation(,)和prev_permutation(,) 在STL中,除了next_permutation(,)外,还有一个函数prev_permutation(,),两者都是用来计算排列组合的函数。前者是求出下一个排列组合,而后者是求出上一个排列组合。...原创 2018-04-24 21:38:09 · 400 阅读 · 0 评论 -
set容器结构体排序
以下是按score从大到小排#include <set>#include <iostream>using namespace std; struct Info{ string name; int score; bool operator<(const Info &a) const { return a.score<score; }...原创 2018-04-25 10:03:43 · 634 阅读 · 0 评论 -
STL中关于二分查找的函数lower_bound 、upper_bound 、binary_search
不知原出处。。。 STL中关于二分查找的函数有三个lower_bound 、upper_bound 、binary_search 。这三个函数都运用于有序区间(当然这也是运用二分查找的前提),下面记录一下这两个函数。ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个...转载 2018-04-25 19:38:27 · 183 阅读 · 0 评论 -
(STL—lower_bound 、upper_bound应用 )ZOJ Problem Set - 2029 The Intervals 详解
点击打开链接查看函数解释 it=x.lower_bound(b);//返回第一个大于或等于b的数的位置 ir=x.upper_bound(b);//返回第一个大于b的数的位置例题:The IntervalsTime Limit: 2 Seconds Memory Limit: 65536 KBCantor, the famous mathematician, was w...原创 2018-04-25 19:47:07 · 211 阅读 · 0 评论 -
(并查集+STL—map和set的结合应用)ZOJ Problem Set - 3641 Information Sharing 详解
Information SharingTime Limit: 3 Seconds Memory Limit: 65536 KBThere is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher has alrea...原创 2018-04-26 14:50:54 · 275 阅读 · 0 评论