《数据结构与算法设计》课程设计报告
题目:
学生姓名: 学 号: 班 级: 指导教师:
2012年 月 日
============第一个=============== #include
#include
char name[10]; char age[3]; char phone[14]; char id[19];
char address[26]; char qq[12]; char emil[20]; char like[20]; char time[10]; node *next; };
node *head[5]; int tense; //比较大小
int cmp(int i,node *p,node *q) {
if(i==1)
return strcmp(p->name,q->name); else if(i==2)
return p->age-q->age; else if(i==3)
return strcmp(p->qq,q->qq); else
return strcmp(p->address,q->address); }
void insert(node *q,int t) {
node *p;
// cout<<\\\\\\ if(head[t]==NULL) {
\\
head[t]=q;
//cout<<\\\\\\\\ } else {
if(cmp(tense,head[t],q)>0) {
q->next=head[t]; head[t]=q;
// cout<<\
\\\\\\\ // cout<<\ } else {
node *s; p=head[t]; s=p;
while(p!=NULL&&cmp(tense,p,q)<0) {
s=p;
p=p->next; }
q->next=p; s->next=q;
//cout<<\\\\\\\\ } } }
void start() {
int t; node *p; ifstream in;
in.open(\ if(!in)
cout<<\打开文件有异常\ else {
char name[8]; in>>name;
while(strcmp(name,\ {
p=new node;
strcpy(p->name,name);
in>>p->age>>p->phone>>p->id>>p->address>>p->qq>>p->emil>>p->like>>p->time; p->next=NULL; // cout<
if(strcmp(p->time,\小学\ t=1;
else if(strcmp(p->time,\中学\ t=2;
else if(strcmp(p->time,\高中\ t=3;
else if(strcmp(p->time,\大学\ t=4;
// cout<
//cout< in.close(); } void print() { for(int i=1;i<=4;i++) { cout<<\ node *p; p=head[i]; while(p!=NULL) { cout< void sort(int i) { node *q; while(head[i]!=NULL) { q=head[i]; head[i]=head[i]->next; q->next=NULL; insert(q,0); } head[i]=head[0]; head[0]=NULL; } void search(char *s) { node *p; int y=0; for(int i=1;i<=4;i++) \\