STL 合集

poj 2419 SET

    set<
int
>
s[
300
];

   for
(
i=
0
;
 i<
110
;
 i++)

s[ i]. clear ();
while ( scanf ( "%d%d" , & i,& j)!= EOF)
{
s[ i]. insert ( j);
}
if ( s[ i]== s[ j])
flag[ j]= 1 ;



poj 1547 MAP
map< int , string> stu;
while ( scanf ( "%d" , & n))
{
stu. clear ();
if ( n==- 1 )
break ;
int a, b, c;
for ( i= 0 ; i< n; i++)
{
scanf ( "%d%d%d%s" ,& a,& b,& c, ch);
stu[ a* b* c]=( string) ch;
}
printf ( "%s took clay from %s. /n " ,( stu. rbegin ()-> second). c_str (),( stu. begin ()-> second). c_str ()); ///////转化成 C语言中的c类型
}
}

poj 1731

string st;
cin>> st;
sort ( st. begin (), st. end ());
do
{
cout<< st<< endl;
} while ( next_permutation ( st. begin (), st. end ()));


sort 和 next_permutation对于 string 的用法,都是传的一个指针
string 的用法 .里面可以赋值. 
string rep(string s,string t,string r)
{
    int i,j,k,l=s.length(),m=t.length();
    string res="";
    for (i=0;i<l;i++)
    {
        for (j=i,k=0;j<i+m&&j<l;j++,k++)
        {
            if (s[j]!=t[k])break;
        }
        if (j==i+m)
        {
            res+=r;//r 是string
            i+=m-1;
        }
        else
        {
            res+=s[i];///res 和 s都是string
        }
    }
    return res;
}
string replace 的函数 。里面还包括string.insert 和string.erase 的操作.
void string_replace(string & strBig, const string & strsrc, const string &strdst,int id) {
        string::size_type pos=0;
        string::size_type srclen=strsrc.size();
        string::size_type dstlen=strdst.size();
//        cout<<strBig<<"***"<<endl;
        while( (pos=strBig.find(strsrc, pos)) != string::npos)
        {
                strBig.erase(pos, srclen);
                strBig.insert(pos, strdst);

                pos += dstlen;;
        }
         if(strBig.size()<=b.size())
          {
            tail=(tail+1)%loop;
            q[tail].str=strBig;
            q[tail].id=id+1;
//            cout<<strBig<<endl;
          }

}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值