poj 1208 The Blocks Problem 模拟+vector的使用
2015-01-31 03:48
441 查看
模拟水题,直接贴代码,主要是vector的使用。
//poj 1208 //sep9 #include <iostream> #include <vector> using namespace std; const int maxN=32; vector<int> v[maxN],tmp; char a[32],b[32]; int n,x,y,a1,a2,b1,b2; void get_address() { int i,j; for(i=0;i<n;++i) for(j=0;j<v[i].size();++j) if(v[i][j]==x){ a1=i; b1=j; } for(i=0;i<n;++i) for(j=0;j<v[i].size();++j) if(v[i][j]==y){ a2=i; b2=j; } } void show() { int i,j; for(i=0;i<n;++i){ printf("%d:",i); for(j=0;j<v[i].size();++j) printf("% d",v[i][j]); printf("\n"); } } void a_move_back() { int i; tmp.clear(); for(i=b1+1;i<v[a1].size();++i) tmp.push_back(v[a1][i]); v[a1].erase(v[a1].begin()+b1+1,v[a1].end()); for(i=0;i<tmp.size();++i){ int x=tmp[i]; v[x].insert(v[x].begin(),x); } } void b_move_back() { int i; tmp.clear(); for(i=b2+1;i<v[a2].size();++i) tmp.push_back(v[a2][i]); v[a2].erase(v[a2].begin()+b2+1,v[a2].end()); for(i=0;i<tmp.size();++i){ int x=tmp[i]; v[x].insert(v[x].begin(),x); } }
相关文章推荐
- uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟
- uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟
- poj 1208 The Blocks Problem (链表模拟)
- POJ 1208 The Blocks Problem [模拟]
- POJ 1208 The Blocks Problem (模拟)
- POJ 1208 The Blocks Problem(模拟)
- POJ 1208 The Blocks Problem 栈模拟 练STL
- POJ 1208 TheBlocks Problem (模拟+队列)
- POJ-模拟-1208 The Blocks Problem
- POJ 1208 The Blocks Problem (UVA 101)
- UVa101-The Blocks Problem/STL-Vector的使用
- UVa 101 The Blocks Problem 【STL】【vector】【模拟】
- POJ 1208 The Blocks Problem
- UVAThe blocks problem VECTOR的使用
- POJ 1208 The Blocks Problem
- POJ 1208 The Blocks Problem
- POJ-1208-The Blocks Problem
- poj 1208 The Blocks Problem
- Problem B The Blocks Problem(vector的使用)
- poj1208 The Blocks Problem,模拟,vector