| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:[求助]队列接受显示的问题
只看楼主 加入收藏
tiancaion3
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-10-25
收藏
 问题点数:0 回复次数:2 
[求助]队列接受显示的问题

用队列接受并且显示,麻烦大大帮下忙,现在能接受2个数,但是只能显示第一个的,我要怎样做才能显示出2个来,搞了7.8个小时了,郁闷得很

#include <iostream>
#include <string>
using namespace std;
class node
{
private:
string data;
string name;
public:
node *Next;
void add_data(const string &d);
string disp_data();
void disp()
{
cout<<"\nCustomer data :\t"<<data;
cout<<"\nName :\t"<<name;
}
};
void node::add_data(const string &d)
{
data=d;
cout<<"\nEnter Customer Name\t";
getline(cin,name);
}
string node::disp_data()
{
return disp();
}
class queClass
{
node *FRONT, *REAR;
public:
queClass(void);
void add_node(string &d);
bool del_node();
};

queClass::queClass()
{
FRONT=NULL;
REAR=NULL;
}

void queClass::add_node(string &d)
{
node *Fresh;
Fresh = new node;
Fresh->add_data(d);
Fresh->Next = NULL;
if(FRONT==NULL)
{
FRONT=Fresh;
REAR=Fresh;
}
else
{
REAR->Next=Fresh;
REAR=Fresh;
}
}

bool queClass::del_node()
{
node *temp;
int ctr=1;
if (FRONT==NULL)
return false;
while(FRONT!=NULL)
{
temp=FRONT;
FRONT=FRONT->Next;
cout<<"Candidate\t"<<ctr<<"\t is "<<temp->disp_data()<<endl;
ctr++;
delete temp;
}
return true;
}
int main()
{
queClass q1;
string val;
char choice='y';
while(choice=='y')
{
cout<<"Are there any more people in Queue (y/n)?";
cin>>choice;
if(choice == 'n')
break;
cout<<"\n\n Enter name of Person in the Queue\n\n";
cin.ignore();
getline(cin,val);
q1.add_node(val);
}
cout<<"The Order of Interview Time on First-cum-first basis of all the ,candidates is as follows:\n";
if (q1.del_node()==false)
cout<<"No candidates for Interview\n";
system("PAUSE");
}

搜索更多相关主题的帖子: 队列 
2006-10-25 22:36
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
没有注释很闹心
既然你说看了很长时间
估计你不会出一般错误
我就不找了
这里你试试void node::add_data(const string &d)
{
data=d;
cout<<"\nEnter Customer Name\t";
cin.ignore(100,'\n');
getline(cin,name);
}

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-10-25 23:46
tiancaion3
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-10-25
收藏
得分:0 

不行........
用链表成吗?但是我不知道怎么用POP和PUSH和链表连接,在学校里面老师又没讲,就直接出题,说交不出来平时练习的分没了.....自己最先试了半天结果还是不知道怎么连,麻烦能指点下吗

2006-10-26 00:31
快速回复:[求助]队列接受显示的问题
数据加载中...
 
   



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

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