标签:style blog http color os ar for sp strong
12模拟链表,约瑟夫环。。来自一个失败的题意理解。。
var a,b:array[0..10] of longint; n,i,t,k,j,p,m:longint; begin //readln(n); n:=10; for i:=1 to n do a[i]:=i; for i:=1 to n-1 do b[i]:=i+1; b[n]:=1; m:=0; t:=n; repeat for j:=1 to 3 do begin p:=t; t:=b[t]; end; b[p]:=b[t]; inc(m); until m=8; writeln(b[p]); t:=p; for k:=1 to 20 do begin write( a[t],‘ ‘ ); t:=b[t]; // end; end.
3
标签:style blog http color os ar for sp strong
原文地址:http://www.cnblogs.com/xin-le/p/4066308.html