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 |
Help~~I've sovled it, but I wander what data trapped my origin code. Please help me!Thanks very much! #include <iostream> using namespace std; int org[3001]; int adj[3001][2]; int main(){ int len, i, j, one= 0, k; scanf("%d",&len); memset(adj,0,sizeof(adj)); for( i= 0; i< len; i++ ){ scanf("%d",&adj[i][0]); if( adj[i][0] ) one++; } for( i= len-1; i>= len-one; i-- ) adj[i][1]= 1; for( k= 0, i= 0; k< len; k++ ){ org[k]= adj[i][0]; adj[i][0]= -1; for( j= 0; j< len; j++ ) if( adj[i][1]== adj[j][0] ){ i= j; break; } } for( i= 1; i< len; i++ ) printf("%d ",org[i]); printf("%d \n",org[0]); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator