前言:
相对于新生,更针对ACM新生,尽可能贴近ACM比赛时的使用,不会过于细致.若要深究,希望自行研究.若发现有不足或疑问,可留言
String:
C++
#include <iostream> #include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <set> #include <queue> using namespace std; int main() { // freopen("in.in","r", stdin); string str, tmp; //----初始化string字符串 str = "abcdef"; cout<<str<<endl; //----在后面追加字符'g' str+='g'; cout<<str<<endl; //----在后面追加字符串"hijk" str+="hijk"; cout<<str<<endl; //----输出第3个字符d cout<<str[3]<<endl; //----使用大小于号比较字符串 tmp = "bcdef"; cout<<(tmp>str)<<endl; tmp = "abcdefghijk"; //----删除字符 cout<<(tmp == str)<<endl; //----清空字符串 str.clear(); cout<<str<<endl; return 0; }
#include <iostream> #include <cstdio> #include <string> #include <cstdlib> #include <cstring> #include <set> #include <queue> usingnamespacestd; intmain() { // freopen("in.in","r", stdin); stringstr,tmp; //----初始化string字符串 str="abcdef"; cout<<str<<endl; //----在后面追加字符'g' str+='g'; cout<<str<<endl; //----在后面追加字符串"hijk" str+="hijk"; cout<<str<<endl; //----输出第3个字符d cout<<str[3]<<endl; //----使用大小于号比较字符串 tmp="bcdef"; cout<<(tmp>str)<<endl; tmp="abcdefghijk"; //----删除字符 cout<<(tmp==str)<<endl; //----清空字符串 str.clear(); cout<<str<<endl; return0; }
Set:
Queue:
Stack:
Map:
Rope:
Rope的使用基本函数