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 |
1A水过。。。。。给不会的一点提示吧因为父进程不会打印Process那句,所以只要反过来递归子进程之前先打印了这句,子进程就能从loop开始了 诶,语文太差,感觉没说清楚,直接贴代码吧 #include <stdio.h> int n,k,id; int dfs(int A,int loop) { int i=loop,_id=id++; for(;i<n;++i) { if(0 == --k) { printf("Loop %d: Process ID=%d\n",i,_id); return 1; } A+=7; if(0 == --k) { printf("Process ID=%d, A=%d\n",id,A); return 1; } if(1 == dfs(A,i+1)) { return 1; } } return 0; } int main() { int T; scanf("%d",&T); while(T--) { scanf("%d %d",&n,&k); id=1000; dfs(0,0); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator