C++STL 好文收集处

1 篇文章 0 订阅

sort函数

http://www.cnblogs.com/joyclub/p/4474663.html


string 的 find()函数

http://www.cnblogs.com/zpcdbky/p/4471454.html

参考PAT1052

	int pos1=line1.find("[");
	int pos2;
	while(pos1<=line1.size()){
		pos2=line1.find("]",pos1);                    //找pos1之后的"]"
		shou[size_s]=line1.substr(pos1+1,pos2-pos1-1);
		//cout<<size_s<<" "<<shou[size_s]<<endl;
		size_s++;
		pos1=line1.find("[",pos2);
	}


map用法详解

http://www.cnblogs.com/fnlingnzb-learner/p/5833051.html

先收录几个自己用惯了的。(应用参考 PAT 1039)

map 的插入。

map <char,node> zhuzi;
struct node temp;
zhuzi.insert(pair<char,node>(b[i],temp));

map的查找。

zhuzi.count(b[i]);//存在返回1,不存在返回0

map的遍历
	map<char,node>::iterator iter;
	for(iter=zhuzi.begin();iter!=zhuzi.end();iter++){
		cout<<iter->first<<" "<<iter->second.now<<endl;
	}





string 的 substr()函数

// string::substr
#include <iostream>
#include <string>

int main ()
{
  std::string str="We think in generalities, but we live in details.";
                                           // (quoting Alfred N. Whitehead)

  std::string str2 = str.substr (3,5);     // "think"

  std::size_t pos = str.find("live");      // position of "live" in str

  std::string str3 = str.substr (pos);     // get from "live" to the end

  std::cout << str2 << ' ' << str3 << '\n';

  return 0;
}

vector

http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值