C++STL多香啊,以后字符串就用string,说什么也不用char了!就算要用也要知道怎么转换成string……
例题:poj 2503 -- Babelfish
1、怎么快速读入string?inline string readstr(){
string ans="";
char c=getchar();
while(s==' '||s=='n') c=getchar();
while(s!=' '&&s!='n'){
ans+=c;
c=getchar();
}
return ans;
}
2、char[]转化为string
#include#include #include #include using namespace std; int main(){ char s[10]; gets(s); string ss; ss.assign(s,strlen(s)); cout< 3、查找字符串中指定位置与分割 #include#include #include #include



