oier选队长 高手进

var a:array[0..101]of boolean; i,j,n,sum,x,y:longint; f:boolean;begin fillchar(a,sizeof(a),true);a[0]:=false;a[101]:=false; readln(n);f:=true;j:=0;i:=0;sum:=100; while sum>2 do begin if f then begin while a[i]=false do inc(i); inc(j);dec(sum); end else begin while a[i]=false do dec(i); inc(j);dec(sum); end; if j mod 3=0 then a[i]:=false; if ((i=100)and(f)) then begin inc(i); j:=0; f:=false end else if ((i=1)and(f=false)) then begin dec(i); j:=0; f:=true; end; end; for i:=1 to 100 do begin if a[i] then if x=0 then x:=i else y:=i; end; if f then writeln(x) else writeln(y);end.因为是直接打有可能会编译出错
program aa;type arr=record hou:integer;end;vara:array [1..120] of arr;i,n,t,ff:integer;begin readln(n); for i:= 1 to n-1 do begin a[i].hou:=i+1; end; a[n].hou:=1; t:=1; repeat n:=n-1; if n>2 then begin t:=a[t].hou; a[t].hou:=a[a[t].hou].hou; t:=a[t].hou; end else begin ff:=t; break; end; until n=0; writeln(ff);end.程序已调试好使,不过没看懂楼主的输入样例,数据还是楼主自己测试吧~
文章标签:

本文链接:https://www.u1e.cn/baike/a/408083c42c034cac44a55a31 [复制]

猜你喜欢

歇后语大全

还没有人回应过