一道pascal编程题,帮忙解一下,最好用数组解,千恩万谢
来源:百度知道 编辑:UC知道 时间:2024/05/25 17:23:12
program sd;
const mun=50;
var
a:array[1..num] of integer;
i,p,q,t,m,n:integer;
begin
readln(n,m);
for i:=1 to n-1 do a[i]:=i+1;
a[n]:=1;
q:=n; p:=n; t:=0;
repeat
p:=a[p];
t:=t+1;
if (t mod m<>0) then q:=p
else a[q]:=a[p];
until (p:=a[p]);
writeln('The total number:',n:3);
writeln('The max number:',m:3);
writeln('The KINK is:',a[p]:3);
readln;
end.
没错的!可以照抄!
program mk;   
var a:array[1..1000]of boolean;
step,i,j,b,n,k:longint;
begin
   readln(n,step);
   fillchar(a,sizeof(a),true);
   for i:=1 to n-1 do
     begin
       b:=0;
       repeat
         inc(j);
         if j>n then j:=j m