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;
}
}
302

被折叠的 条评论
为什么被折叠?



