2、:Boolean; varI:integer; begin forI:=2totrunc(sqrt(n))do ifnmodI=0thenbegin prime:=false;exit;end; prime:=true; end;B.判断longint范围内的数是否为素数(包含求50000以内的素数表): proceduregetprime; var i,j:longint; p:array[1..50000]ofboolean; begin fillchar(p,sizeof(p)
4、 vari:integer; begin prime:=false;fori:=1toldo ifpr[i]>=xthenbreak elseifxmodpr[i]=0thenexit;prime:=true; end;{prime}二、图论算法1.最小生成树A.Prim算法: procedureprim(v0:integer); var lowcost,closest:array[1..maxn]ofinteger;i,j,k,min:integer; begin for