91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 21KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-06
  • 語言: C/C++
  • 標簽:

資源簡介

元胞自動機模型源代碼,模擬緊急事件下人員疏散問題

資源截圖

代碼片段和文件信息

#include?“stdafx.h“
#include?“iVPS.h“
#include?“math.h“
#include?“time.h“
#include?“iostream.h“


int?Np=50;?//初始化人數(shù)
int?timestep=0;
LNode?*s;
int?count=0;


fstream?vfile;//open?file?to?save?density?data;
fstream?ffile;//?open?file?to?save?flow?rate?data;
fstream?cfile;?//open?file?to?save?the?count?of?each?type?of?pedestrians;

//=================鏈表操作================================
bool?ListInsert(LNode??*sint?iint?xint?y)
{
int?peoplenum=s->per.index;
LNode?*p_temp=s;
while(p_temp->next!=NULL)//error
{
p_temp=p_temp->next;
}
LNode?*news;
if((news=(LNode*)malloc(sizeof(LNode)))!=NULL)
{
p_temp->next=news;
news->next=NULL;
news->per.index=i;
news->per.location.x=x;
news->per.location.y=y;
news->per.s=0;
s->per.index=i;
return?true;
}
else
return?false;
}

struct?LNode?*ListFind(LNode?*s?int?index)
{
LNode?*p_temp=s;
while(p_temp->next!=NULL)
{
if(p_temp->next->per.index==index)
return?p_temp->next;
else
p_temp=p_temp->next;
}
return?p_temp;
}

struct?LNode?*?Listdelete(LNode?*sint?xint?y)
{
int?pernum=s->per.index;
LNode?*p_temp=s->next?;
LNode?*p_pre=s;//p_temp

while(p_temp->per.location.x?!=?x?||?p_temp->per.location.y!=y)
{
p_pre=p_temp;
p_temp=p_temp->next;
}
p_pre->next?=p_temp->next;
p_temp->next=NULL;
free(p_temp);
p_temp=NULL;
s->per.index=pernum-1;
return?p_pre;
}

bool?randomseq(LNode?*s)
{
LNode?*p_temp=s;
while(p_temp->next!=NULL)//error
{
int?rand1=(int)(rand()/(double)RAND_MAX)*(Np-1);
struct?LNode?*p;
LNode?temp;
p=ListFind(srand1);

p_temp->next->per.s=0;//清空方向記錄;
p->per.s=0;

temp.per.index=p_temp->next->per.index;
temp.per.location.x=p_temp->next->per.location.x;
temp.per.location.y=p_temp->next->per.location.y;

p_temp->next->per.index=p->per.index;
p_temp->next->per.location.x=p->per.location.x;
p_temp->next->per.location.y=p->per.location.y;

p->per.index=temp.per.index;
p->per.location.x=temp.per.location.x;
p->per.location.y=temp.per.location.y;

p_temp=p_temp->next;
}
return?true;
}
//==============================================================
bool?initparam()
{//20
????int?ij;
//========初始化通道==============
for(?i=0;i {//3
if(i==0||i==RoomWidth-1)
{//1
for?(j=0;j Ch[i][j]=-1;
Ch[RoomWidth-1][RoomLength/2]=0;
Ch[RoomWidth-1][RoomLength/2-1]=0;
Ch[RoomWidth-1][RoomLength/2+1]=0;
Ch[RoomWidth-1][RoomLength/2+2]=0;
}//1
else
{//2
for(j=0;j if(j==0||j==RoomLength-1)
{
Ch[i][j]=-1;
}
else
Ch[i][j]=0;

}//2
}//3


//========初始化人群==============
if((s?=?(LNode*)?malloc?(sizeof(LNode)))!=NULL)
{//6
s->per.index=0;
s->next=NULL;
}//6
for(?i=1;i<=Np;i++)
{//8
int?xy;

do
{
double?rand1=(rand()/(double)RAND_MAX);
double?rand2=(rand

評論

共有 條評論