|
#define totaltime=480;
main()
{
int t,totalsum=0;
float length[5][7]={{5.26,5.19,4.21,2.95,1.90,0.64,1.27},
{1.90,0.99,1.90,1.27,2.04,3.09,3.51},
{5.89,5.61,5.61,3.51,2.46,1.06,0.57},
{0.64,1.76,1.27,2.74,3.72,5.05,6.10},
{4.42,3.86,3.72,2.25,1.62,1.27,0.50}};
float cast[3][7]={{0.95,1.05,1.00,1.10,1.30,1.35,1.25},
{1.25,1.10,1.35,1.15,1.15,1.35,1.25},
{0.30,0.28,0.29,0.31,0.31,0.33,0.31}};
float temp;
float time[5][7];
int aa[7]={0,0,0,0,0,0,0};
int bb[5]={0,0,0,0,0};
int canpos[5][7];
float linestatus[5][7]={{81.688,27.818,41.138,9.087,0,0,0},
{0,0,0,14.697,11.584,87.662,46.056},
{0,0,35.233,0,46.16,8.337,17.852},
{0,14.693,0,0,38.255,0,32.090},
{14.831,54.112,19.627,71.428}};
int carstatus[20][5];
int carsum[2][7];
float xiestatus[5]={0,0,0,0,0};
float cangchesta[2][7];
int i,j,inttemp;
for(i=0;i<5;i++)
for(j=0;j<7;j++)
time[j]=length[j]*60.0/28.0;
printf("--------------------Time table------------------------\n");
temp=0;
for(i=0;i<5;i++)
{
for(j=0;j<7;j++)
{printf("%5.2f ",time[j]);temp=temp+time[j];}
printf("\n");
}
printf("Total:%6.2f\n",temp);
printf("\n--------------------Carsum table----------------------\n");
for(i=0;i<2;i++)
for(j=0;j<7;j++)
carsum[j]=cast[j]*10000/154;
inttemp=0;
for(i=0;i<2;i++)
{
for(j=0;j<7;j++)
{printf("%5d ",carsum[j]);inttemp+=carsum[j];}
printf("\n");
}
for(i=0;i<5;i++)
for(j=0;j<7;j++)
canpos[j]=(time[j]*2.0+8.0)/5.0;
printf("\n--------------------Can termate car number---------------\n");
for(i=0;i<5;i++)
{
for(j=0;j<7;j++)
printf("%5d ",canpos[j]);
printf("\n");
}
for(i=0;i<2;i++)
for(j=0;j<7;j++)
cangchesta[j]=cast[j];
printf("\n--------------------Can tried number---------------\n");
for(i=0;i<5;i++)
{
for(j=0;j<7;j++)
printf("%5.1f ",linestatus[j]);
printf("\n");
}
for(i=0;i<20;i++)
for(j=0;j<5;j++)
carstatus[j]=0;
totalsum=0;
for(i=0;i<7;i++)
{
carstatus[0]=cheshi(aa,7)+1;
aa[cheshi(aa,7)]=1;
carstatus[4]=5;
}
for(t=1;t<=480;t++)
{
for(i=0;i<20;i++)
{
if(zeroc(carstatus,5)!=0)
{
carstatus[4]-=1;
if(carstatus[4]==0)
{
temp=nozero(carstatus,4);
switch (temp)
{
case 0:
carstatus[3]=1;
aa[carstatus[0]-1]=0;
carstatus[0]=0;
.......
break;
case 1:
carstatus[1]=0;
totalsum++;
........
break;
case 2:
carstatus[2]=0;
break;
........
case 3:
carstatus[3]=0;
.........
break;
}
}
}
if(zeroc(carstatus,5)==0&&cheshi(aa,7)!=-1)
{
carstatus[0]=cheshi(aa,7)+1;
aa[cheshi(aa,7)]=1;
carstatus[4]=5;
}
}
}
}
int cheshi(int *pp,int length)
{
int i,sum;
sum=0;
for(i=0;i<length;i++)
{
if (pp==0)
return i;
}
return -1;
}
int zeroc(int *pp,int length)
{
int i,sum;
sum=0;
for(i=0;i<length;i++)
sum=sum+pp;
return sum;
}
int nozero(int *pp,int length)
{
int i,sum;
sum=0;
for(i=0;i<length;i++)
if(pp!=0) return i;
return -1;
} |
|