没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
public class Car {
public static void main(String[] args) {
int[] speed1=new int[6];//统计结果
int count=0;
int probability=15;//出现车的可能
int num=100;//初始化车辆
int n=600;//总路程
int nn=360;//监视时间
int[] appear=new int[1];
int[] circulation=new int[n];//统计流量
int[][] che=new int[2][n];
chuShiHua(che,n);
initSpeed(che,n,num,appear);
repair(che,n);
//车流变化
for(int j=0;j<nn;j++){
for(int m=1000;m>0;m--)
for (int i = 1000; i >0; i--) ;
output(che,n,j+1,speed1,circulation);
move(che, n);
if(j%2==0)
add(che, n,probability,appear);
if(j%3==0)
over(che, n);
if(j%4==0||j%6==0)
back(che, n);
if(j%5==0)
if(probability>55)
addspeed(che, n);
else if(((int) (Math.random()*100))>55)addspeed(che, n);
if(j%5==0)
if(probability<75)
addspeed(che, n);
else if(((int) (Math.random()*100))>65)addspeed(che, n);
}
System.out.println("出现不同速度的车的数目");
for(int i=0;i<6;i++){count=count+speed1[i];System.out.print(speed1[i]+" ");}
System.out.println("高速车出现的比率:"+(speed1[4]+speed1[5])/(float)count+"中车出现的比率:"+(speed1[2]+speed1[3])/(float)count+
"低速车出现的比率:"+(speed1[0]+speed1[1])/(float)count);
float hh=(speed1[4]+speed1[5])/(float)count;
System.out.println("车道经过车辆数");
for(int i=0;i<n;i++){System.out.print(circulation[i]+" ");}
System.out.println("车流平均密度");
count=0;
for(int i=0;i<n;i++){count=count+circulation[i];System.out.print(i+"="+circulation[i]/(float)nn+"**");}
float cc=count/(float)n/nn;
System.out.println("\n平均车流密度:"+cc);
System.out.println("\n总车数:"+appear[0]*6);
System.out.println("\n安全性:"+appear[0]*cc*hh/6);
}
public static void chuShiHua(int[][] che,int n) {//初始化数组
for(int j=0;j<2;j++)
for(int k=0;k<n;k++){
che[j][k]=0;
}
if(probability>55)
addspeed(che, n);
else if(((int) (Math.random()*100))>55)addspeed(che, n);
if(j%5==0)
if(probability<75)
addspeed(che, n);
else if(((int) (Math.random()*100))>65)addspeed(che, n);
}
System.out.println("出现不同速度的车的数目");
for(int i=0;i<6;i++){count=count+speed1[i];System.out.print(speed1[i]+" ");}
System.out.println("高速车出现的比率:"+(speed1[4]+speed1[5])/(float)count+"中车出现的比率:"+(speed1[2]+speed1[3])/(float)count+
"低速车出现的比率:"+(speed1[0]+speed1[1])/(float)count);
float hh=(speed1[4]+speed1[5])/(float)count;
System.out.println("车道经过车辆数");
for(int i=0;i<n;i++){System.out.print(circulation[i]+" ");}
System.out.println("车流平均密度");
count=0;
for(int i=0;i<n;i++){count=count+circulation[i];System.out.print(i+"="+circulation[i]/(float)nn+"**");}
float cc=count/(float)n/nn;
System.out.println("\n平均车流密度:"+cc);
System.out.println("\n总车数:"+appear[0]*6);
System.out.println("\n安全性:"+appear[0]*cc*hh/6);
}
public static void chuShiHua(int[][] che,int n) {//初始化数组
for(int j=0;j<2;j++)
for(int k=0;k<n;k++){
che[j][k]=0;
}
剩余6页未读,继续阅读
资源评论
- sinat_218626272015-10-30很好,很实用
夏日绝句
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功