讨论 / 求救啊,我的程序为什么是死循环啊,大牛们拜托了,现在没积分了,以后一定追加啊
小胖无敌 2013-06-06 20:36:00
点我顶贴 收藏 删除
program zuoye;

var m,n,i,j,len,k,t1,t2,t3,t4:longint;

cishu:array[1..20]of longint;

cixu:array[1..400]of longint;

shun:array[1..20,1..20]of longint;

time:array[1..20,1..20]of longint;

ma:array[1..20,1..5000]of boolean;

{function find(x,y:longint):longint;

var i,j,k,t:longint; p:boolean;

begin

i:=1; t:=1;

while i<=maxlongint do

begin

t:=i;

if ma[x,i]=true then begin

p:=true;

for j:=i to i+y-1 do

if ma[x,j]=false then begin

p:=false;

k:=j;

break;

end;

if p=true then begin

find:=i;

exit;

end;

if p=false then i:=k+1;

end;

if i=t then inc(i);

end;

end;}

function find(x,y:longint):longint;

var i,k:longint;

p:boolean;

begin

i:=1;

repeat

if ma[x,i]=false then inc(i)

else

begin

p:=true;

for j:=i to i+y-1 do

if ma[x,j]=false then begin

p:=false;

k:=j;

break;

end;

if p=true then begin

find:=i;

exit;

end;

if p=false then i:=k+1;

end;

until i>10000;

end;

begin

assign(input,'a.in');

assign(output,'a.out');

reset(input); rewrite(output);

fillchar(cishu,sizeof(cishu),1);

fillchar(ma,sizeof(ma),true);

readln(m,n);

for i:=1 to m*n do

read(cixu[i]);

readln;

for i:=1 to n do

begin

for j:=1 to m do

read(shun[i,j]);

readln;

end;

for i:=1 to n do

begin

for j:=1 to m do

read(time[i,j]);

readln;

end;

len:=-1;

for i:=1 to m*n do

begin

t1:=cixu[i];{处理第t1个产品}

t2:=cishu[t1];{第t1个产品的第t2个工序}

t3:=shun[t1,t2];{工序在t3机器上}

t4:=time[t1,t2];{机器上所用时间t4}

k:=find(t3,t4);

for j:=k to k+t4-1 do

ma[t3,j]:=false;

if (k+t4-1)>len then len:=k+t4-1;

inc(cishu[t1]);

end;

writeln(len);

close(input); close(output);

end.

就要比赛了,好心人给看一下吧

#1 hl12321@2014-01-30 11:09:50
回复 删除
还是pascal大神看得清楚些
查看更多回复
提交回复