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

#include<iostream.h>
#include<iomanip.h>
#include<string.h>
struct data
{
int year; int month; int day;
};
struct friends
{
char name[12];
char sex;
char tel[12];
date birthday;
friends* next;
};
int a;
struct friends* create()
{
struct friends *head,*p1,*p2;
a=0;
p1=p2=new friends;
cout<<"Input my friends'name,with'#'to end;"<<endl;
cin>>p1->name;
cout<<"Continue to input my friends'sex(F/M),tel and birthday:"<<endl;
cin>>p1->sex;
cin>>p1->tel;
cin>>p1->birthday.year>>p1->birthday.month>>p1->birthday.day;
head=NULL;
while(strcmp(p1->name,"#")!=0)
{
a++;
if(a==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=new friends;
cout<<"Input my friends'name,with'#'to end;"<<endl;
cin>>p1->name;
if(strcmp(p1->name,"#")!=0)
{
cout<<"Continue to input my friends'sex(F/M),tel and birthday:"<<endl;
cin>>p1->sex;
cin>>p1->tel;
cin>>p1->birthday.year>>p1->birthday.month>>p1->birthday.day;
}
}
p2->next=NULL;
return head;
}
void print(struct friends* head)
{
struct friends* p;
p=head;
cout<<setw(11)<<"name"<<setw(5)<<"sex"<<setw(12)<<"telNO."
<<setw(16)<<"birthday"<<endl;
while(p!=NULL)
{
cout<<setw(11)<<p->name<<setw(4)<<p->sex<<setw(16)<<p->tel<<" ";
cout<<setw(5)<<p->birthday.year;
cout<<setw(3)<<p->birthday.month<<" ";
cout<<setw(2)<<p->birthday.day<<endl;
p=p->next;
}
}

void main()
{
friends *s;
s=create();
print(s);
}




以上程序我用VC6.0编译的时候出现21项错误,小弟忘各位给指点下错在那里了

搜索更多相关主题的帖子: 链表 
2007-04-23 22:28
lhlovelk
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2006-1-12
收藏
得分:0 
晕!

怎么没人来呀!

2007-04-24 12:28
快速回复:[求助]一个链表的21个错
数据加载中...
 
   



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

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