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 |
到底怎样才行?我的代码如下,display()错在哪儿了? #include<iostream> #include<cstring> using namespace std; int st[26][26]= {0}; int x[26]; int y[26]; int n; inline void back(int a) { int i,p,c = x[a]; for(i = y[a]+1 ;p = st[c][i];i ++) { x[p] = p;y[p] = 1;st[c][i] = 0;st[p][1] = p; } } void mvov(int a,int b) { back(a); st[x[a]][y[a]] = 0; for(int i = y[b] ;st[x[b]][i];i ++); x[a] = x[b];y[a] = i; st[x[a]][i] = a; } void mvon(int a,int b) { back(b); mvov(a,b); } void plov(int a,int b) { int i,c = x[a],d = x[b],p,h; for(h = y[b];st[x[b]][h];h ++); for(i = y[a];p = st[c][i] ;i ++) { st[c][i] = 0; x[p] = d;y[p] = h++; st[x[b]][h-1] = p; } } void plon(int a,int b) { back(b); plov(a,b); } void display() { int i,j; for(i = 1;i <= n;i ++) { printf(" %d: ",i-1); if(!st[i][1]) ; else for(j = 1;st[i][j];j ++) printf(" %d",(st[i][j]-1)); cout << endl; } } int main() { int a,b,i; void (*f[4])(int,int); char s[10],t[10]; scanf("%d",&n); for( i = 1;i <= n;i ++) { st[i][1] = i;x[i] = i; y[i] = 1; } f[0] = mvon;f[1] = mvov;f[2] = plon;f[3] = plov; scanf("%s",s); while(s[0] != 'q') { scanf("%d%s%d",&a,t,&b); a++;b++; if(x[a] != x[b]) f[2 * strcmp(s,"move") + strcmp(t,"onto")](a,b); scanf("%s",s); } display(); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator