Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请教一下高手,我错在哪了,我是菜鸟啊#include<iostream> #include<vector> using namespace std; int main() { int p=0,n,m,i,j,k=1; vector<char> v2(10); vector<int> v1(10); cin>>m; while(m>0) { cin>>n; for(i=0;i<n;i++) { cin>>v2[i]; v1[i]=v2[i]-48; } vector<int> v; for(i=0,j=0;i<2*n;i++) { if(i-j>=v1[j]&&j<n) { v.push_back(1); j++; } else {v.push_back(0);} cout<<v[i]<<" "; } cout<<endl; for(i=0;i<2*n;i++) { if(v[i]==1) { for(j=i-1;j>=0;j--) { if(v[j]==0){cout<<k<<" ";k=1;v[j]=2;break;} else if(v[j]==2)k++; } } } cout<<endl; m--; } return (0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator