| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 917 人关注过本帖
标题:数据结构作业 大家帮帮忙啊
只看楼主 加入收藏
huangyan6611
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2009-4-29
结帖率:87.5%
收藏
 问题点数:0 回复次数:2 
数据结构作业 大家帮帮忙啊
#include"iostream.h"
#include"stdlib.h"
#include"genQueue.h"

int option(int percents[])
{
    register int i=0,choice=rand()%100+1,perc;
    for(perc=percents[0];perc<choice;perc+=percents[i+1],i++);
    return i;
}

void main()
{
    int arrivals[]={15,20,25,10,30};
    int service[]={0,0,0,10,5,10,10,0,15,25,10,15};
    int clerks[]={0,0,0,0},numofclerks=sizeof(clerks)/sizeof(int);
    int customers,t,i,numofminutes=100,x;
    double maxwait=0.0,currwait=0.0,thereisline=0.0;
    Queue<int>simulQ;
    cout.precision(2)
        for(t=1;t<=numofminutes;t++)
        {
            cout<<"t="<<t;
            for(i=0;i<numofclerks;i++)
                if(clerks[i]<60)
            clerks[i]=0;
                else clerks[i]-=60;
                customers=optiom(arrivals);
                for(i=0;i<customers;i++)
                {
                    x=option(service)*10;
                    simulQ.Enqueue(x);
                    currWait+=x;
                }
                for(i=0;i<numOfClerks&&!simulQ.isEmpty();)
                    if(clerks[i]<60){
                        x=simulQ.Dequeue();
                        clerks[i]+=x;
                        currWait-=x;
                    }
                    else i++;
                    if(!simulQ.isEmpty()){
                        thereIsLine++;
                        cout<<"wait="<<currWait/60.0;
                        if(maxWait<currWait)
                            maxWait=currWait;
                    }
                    else cout<<"wait=0;";
        }
        cout<<"\nFor"<<numOfClerks<<"clerks,there was a line"
            <<thereIsLine/numOfMinutes*100.0<<"% of the time;\n"
            <<"maximum wait time was "<<maxWait/60.0<<"min.";}


哪位高手给编个genQueue.h头文件啊  谢谢啊
搜索更多相关主题的帖子: 作业 数据结构 
2009-11-25 08:45
lurrass
Rank: 1
等 级:新手上路
帖 子:17
专家分:1
注 册:2010-9-13
收藏
得分:0 
我看不懂啊
2010-09-14 12:12
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
收藏
得分:0 
genQueue.h
明显是该代码作者自定义的队列头文件!
2010-09-14 12:18
快速回复:数据结构作业 大家帮帮忙啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018129 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved