#include #include #include using namespace std; int ar[10] = { 12, 45, 234, 64, 12, 35, 63, 23, 12, 55 }; char* str = "Hello World"; int main() { vector vec1(ar, ar+10); vector < char > vec2(str,str+strlen(str)); cout<::iterator p1; for(p1=vec2.begin();p1!=vec2.end(); ++p1) cout< #include #include using namespace std; struct info { string name; float score; bool operator < (const info &a) const { return a.score pq; info in; in.name="Jack"; in.score=68.5; A // 压入队列 in.name="Bomi"; in.score=18.5; pq.push(in); in.name="Peti"; in.score=90; pq.push(in); B //遍历 { cout< #include #include #include using namespace std; struct node { int x; int y; int w; friend bool operator> (const node& a,const node& b) { return (a.w > b.w); } friend bool operator< (const node& a,const node& b) { return (a.w < b.w); } }; int main() { int i; priority_queue < node, vector , greater > que1; priority_queue < node, vector , less > que2; node da[5]; for(i = 0;i < 5;i++) { da[i].x = i; da[i].y = i; da[i].w = i; que1.push(da[i]); que2.push(da[i]); } A //遍历队列1 { cout< #include #include #include using namespace std; string a, b; stack build; vector operate; int length; void dfs(int iPush, int iPop) { if(iPush == length && iPop == length) { for(int i = 0; i < operate.size(); i ++) cout << operate[i] << " "; cout << endl; } if(iPush + 1 <= length) { A //将当前字符出栈 B //记录出栈操作 C //搜索下一一个位置 D //复刚刚出栈的字符,便于下一个搜索 operate.pop_back(); } if(iPop + 1 <= iPush && iPop + 1 <= length && build.top() == b[iPop]) { char tc = build.top(); build.pop(); operate.push_back('o'); dfs(iPush, iPop + 1); build.push(tc); operate.pop_back(); } } int main() { while(cin >> a >> b) { length = a.length(); cout << "[" << endl; dfs(0, 0); cout << "]" << endl; } return 0; }