| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3549 人关注过本帖
标题:[求助]数据结构的课程设计!本人编程还不是最好,希望能求到详细的有解释的代 ...
只看楼主 加入收藏
Jason111111
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-1-10
收藏
 问题点数:0 回复次数:8 
[求助]数据结构的课程设计!本人编程还不是最好,希望能求到详细的有解释的代码!谢
数据结构的课程设计!本人编程还不是最好,希望能求到详细的代码!代码最好写上注释!谢谢各位了!
一、 通讯录管理
设计要求
1. 通讯录采用单链表结构存储;
2. 每个通讯者的信息包括编号、姓名、性别、电话、地址;
3. 有主控菜单,可使用数字来选择菜单项,同时进入相应的功能,具体功能包括:
(1) 通讯录链表的建立
(2) 通讯者结点的的插入
(3) 通讯者结点的查询
(4) 通讯者结点的删除
(5) 通讯录链表的输出
其中,通讯者结点的查询包括按编号查询和按姓名查询。
二、 八皇后问题
在8×8的国际象棋棋盘上,安放8个皇后,要求没有一个皇后能够“吃掉”任何其他一个皇后,即没有两个或两个以上的皇后占据棋盘上的同一行、同一列或同一条对角线。
三、 赫夫曼编码的应用
对输入的一串电文字符实现赫夫曼编码,再对赫夫曼编码生成的代码串进行译码,输出电文字符串。
四、 航班信息的查询与检索
设计要求
1. 每个航班记录包括七项,分别是航班号、起点站、终点站、起飞时间、到达时间、飞机型号和票价;
2. 对飞机航班信息按航班号进行排序;
3. 可按航班的航班号、起点站、到达站、起飞时间以及到达时间等信息进行查询;
4. 按航班号的查找采用二分查找,其他采用顺序查找。

搜索更多相关主题的帖子: 数据结构 课程 代码 解释 
2007-01-12 22:42
e4lich
Rank: 2
等 级:新手上路
威 望:4
帖 子:182
专家分:0
注 册:2006-10-26
收藏
得分:0 
我的要求更简单,只要第四题就够了,如果楼主做好了,可以发给我的,谢谢!e4lich@126.com

我只想变强!     
2007-01-13 01:45
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

八皇后

#define N 20

int x[N]; //当前解
int sum = 0 ; //可行解的数量
int n=8 ; //规模
bool Place( int k )
{
int i,j;
for( j = 1 ; i< k ; j++)
for( i = j+1 ; i <=k ; i++ )
{
if(abs(j-i)==abs(x[j]-x[i])||x[i]==x[j])
{
return false;
}
}
return true;
}

inline void Swap(int &a,int &b) //此处为引用,交换函数.函数调用多,故定义为内联函数.
{
int temp;
temp=a,a=b,b=temp;
}

void Perm(int k,int m) //k表示前缀的位置,m是要排列的数目.
{
if(k==m) //前缀是最后一个位置,此时打印排列数.
{
if(Place (m))
{
for(int i=1;i<=m;i++)
{
printf("%-3d",x[i]);
}
printf("\n");
sum++;
}

}
else
{
for(int i=k;i<m;i++)
{
Swap(x[k],x[i]); //交换前缀,使之产生下一个前缀.
Perm( k+1,m);
Swap(x[k],x[i]); //将前缀换回来,继续做上一个的前缀排列.
}
}
}


倚天照海花无数,流水高山心自知。
2007-01-16 17:15
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
每个代码都很长啊
虽然做过,但手头没有
你不会问

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2007-01-16 17:19
zengzhi8509
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-6-12
收藏
得分:0 
我也要第四个!我的邮箱是zgutt@163.com!拜托
2007-06-12 21:16
abc198709120
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-11-10
收藏
得分:0 
现在还有没有我也要,[email=abc198709120@]abc198709120@[/email]   谢谢了
2007-11-22 22:53
33009067yy
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-12-14
收藏
得分:0 
我要这个一、 通讯录管理
[email]99400387@[/email]
2007-12-14 15:44
ranchgirl
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-12-8
收藏
得分:0 
We want to do nothing, and want LZ to send out everything.

LZ: Please send all your source code to [email]junk@junk.junk[/email]

Thanks!

2007-12-14 22:13
康elon
Rank: 2
来 自:西安
等 级:论坛游民
帖 子:179
专家分:24
注 册:2008-4-6
收藏
得分:0 
通讯录
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#define Node struct node
Node             /*结构体类型定义,包括:姓名、电话号码和联系地址*/
{
 char szName[20];
 char szPhoneNum[12];
 char szAddress[30];
 Node *next;
};
Node *strpHead;  /*全局变量,链表头指针*/
Node *strpCurrent;  /*用于指向当前正在操作的结点*/
 /*函数原型声明*/
void HandleChoice_f(int);
void AddRecord_f();
void InsertNode_f(Node * );
Node *InsertPoint_f(char * );
void MakeNewHead_f(Node * );
void AddToEnd_f(Node * );
void MoveToEnd_f();
void DisplayList_f();
void DeleteRecord_f();
void DelHead_f();
void DelEnd_f(Node * );
void DelMid_f(Node * );
int VerifyDel_f();
void DelNode_f(Node * );
void DelList_f();
void SearchByName_f();
void WriteFile_f();
void LoadFile_f();
void Help_f();

/*主程序*/
int main()
{
 int nChoice;
 system("color 1a");
 printf("             欢迎来到电话簿管理系统                \n");
 system("pause");
 system("cls");
 strpHead=NULL;
 LoadFile_f();
 do
 {printf("   ☆☆☆☆☆☆☆☆☆菜单☆☆☆☆☆☆☆☆☆☆\n");
 printf("   ┌─────────────────────┐  \n");
 printf("        1.增加记录                             \n");
 printf("        2.显示所有记录                       │ \n");
 printf("        3.按名字查找朋友的信息               │ \n");
 printf("        4.删除记录                           │ \n");
 printf("      ★5.请求帮助                             \n");
 printf("        6.退出程序                             \n");
 printf("   └─────────────────────┘  \n");
 printf("               elon制作         \n");
 printf("    请选择代码(1,2,3,4,5,6):");
 scanf("%d",&nChoice);
 HandleChoice_f(nChoice);  /*接受用户的选择*/
 }while(nChoice!=6);
 return 0;
 
}
void HandleChoice_f(int nChoice)   /*根据用户选择nChoice调用相应的函数*/
{
 switch(nChoice)
 {
 case 1:
  AddRecord_f();
  break;
 case 2:
  DisplayList_f();
  break;
 case 3:
  SearchByName_f();
  break;
 case 4:
  DeleteRecord_f();
  break;
 case 5:
  Help_f();
  break;
 case 6:
  WriteFile_f();       /*将链表中的数据写回文件*/
  if(strpHead!=NULL)
  {
   DelList_f();
  }
  break;
 default:
  printf("没有您要的选项!\n");
  break;
 }
}

void AddRecord_f()
{
 Node *strpNew;/*为新记录定义临时指针变量*/
 strpNew=(Node *)malloc(sizeof(Node));/*开辟空间存放新记录数据*/
 getchar();
 printf("姓名:");
 gets(strpNew->szName);
 printf("电话号码:");
 gets(strpNew->szPhoneNum);
 printf("联系地址:");
 gets(strpNew->szAddress);
 InsertNode_f(strpNew);
 system("cls");
}
void InsertNode_f(Node *strpNew)
{
 Node *strpFront;
 Node *strpBack;
 system("cls");
 if(strpHead==NULL)
 {
  strpNew->next=NULL;
  strpHead=strpNew;
 }
 else
 {
  if(strcmp(strpNew->szName,strpHead->szName)>0)
  {
   MakeNewHead_f(strpNew);
  }
  else /*查找新结点的位置*/
  {
   strpCurrent=InsertPoint_f(strpNew->szName);
   strpFront=strpCurrent;
   strpBack=strpCurrent->next;
   if(strpBack==NULL)
   {
    AddToEnd_f(strpNew);
   }
   else
   {
    strpFront->next=strpNew;
    strpNew->next=strpBack;
   }
  }
 }
}
Node *InsertPoint_f(char *szName) /*根据新增记录的姓氏,返回其将插入的正确位置*/
{
 char szTempName[20];
 Node *strpTemp;
 int nTemp;
 if(strpHead->next!=NULL)
 {
  strpCurrent=strpHead;
  strpTemp=strpCurrent->next;
  strcpy(szTempName,strpTemp->szName);
  nTemp=strcmp(szName,szTempName);
  while((nTemp>0)&&(strpCurrent->next!=NULL))
  {
   strpCurrent=strpTemp;
   if(strpCurrent->next!=NULL)
   {
    strpTemp=strpCurrent->next;
    strcpy(szTempName,strpTemp->szName);
    nTemp=strcmp(szName,szTempName);
   }
  }
 }
 else
 {
  strpCurrent=strpHead;
 }
 return(strpCurrent);
}
void MakeNewHead_f(Node *strpNew)/*新结点成为链表的头结点*/
{
 Node *strpTemp;
 strpTemp=strpHead;
 strpNew->next=strpTemp;
 strpHead=strpNew;
}
void AddToEnd_f(Node *strpNew)/*新结点成为链表的尾结点*/
{
 strpNew->next=NULL;
 MoveToEnd_f();
 strpCurrent->next=strpNew;
}
void MoveToEnd_f()/*当前指针移到链表尾*/
{
 strpCurrent=strpHead;
 while(strpCurrent->next!=NULL)
 {
  strpCurrent=strpCurrent->next;
 }
}
void DisplayList_f()
{
 
 strpCurrent=strpHead;
 if(strpCurrent!=NULL)
 {
  printf("\n");
  printf("      姓名             电话号码           联系地址         \n");
  printf("------------------------------------------------------------\n");
  do
  {
   printf("%10s",strpCurrent->szName);
   printf("%20s",strpCurrent->szPhoneNum);
   printf("%20s\n",strpCurrent->szAddress);
   strpCurrent=strpCurrent->next;
   printf("\n");
  }while(strpCurrent!=NULL);
  system("pause");
  system("cls");
 }
 else
 {
  printf("没有记录可以显示!\n");
 }
}
void SearchByName_f()
{
 char szSearch[20];
 strpCurrent=strpHead;
 system("cls");
 getchar();
 printf("\n输入您要查找的姓名:");
 gets(szSearch);
 while((strpCurrent!=NULL)&&(strcmp(strpCurrent->szName,szSearch)!=0))
 {
  strpCurrent=strpCurrent->next;
 }
 if(strpCurrent!=NULL)
 {
  printf("\n记录找到了!\n");
  printf("%s\n",strpCurrent->szName);
  printf("%s\n",strpCurrent->szPhoneNum);
  printf("%s\n",strpCurrent->szAddress);
 }
 else
 {
  printf("没有相应的记录!\n");
  printf("按ENTER键继续\n");
  system("pause");
  system("cls");
 }
}
void DeleteRecord_f()
{
 char szSearch[20];
 Node *strpFront;
 system("cls");
 strpFront=NULL;
 strpCurrent=strpHead;
 getchar();
 printf("\n输入朋友的姓名以删除该记录:");
 gets(szSearch);
 while((strpCurrent!=NULL)&&(strcmp(strpCurrent->szName,szSearch)!=0))
 {
  strpFront=strpCurrent;
  strpCurrent=strpCurrent->next;
 }
 if(strpCurrent!=NULL)
 {
  printf("\n记录找到了\n");
  printf("%s\n",strpCurrent->szName);
  printf("%s\n",strpCurrent->szPhoneNum);
  printf("%s\n",strpCurrent->szAddress);
  if(VerifyDel_f())
  {
   DelNode_f(strpFront);
   printf("\n该记录已经删除!\n");
  }
  else
  {
   printf("\n该记录没有删除!\n");
  }
 }
 else
 {
  printf("\n没有匹配的记录被删除!\n");
 }
 system("cls");
}
void Help_f()
{
 int nChoice;
 do
 {
  system("cls");
  printf("欢迎来到帮助栏,请选择代号\n");
  printf("1:电话簿的功能\n");
  printf("2:怎么清除所有记录\n");
  printf("3:在加入新的信息时,原来的信息还在吗\n");
  printf("4:你操作时需要注意的事项!\n");
  printf("5:退出\n");
  scanf("%d",&nChoice);
  switch(nChoice)
  {
  case 1:
   printf("这是一个简单的电话簿,刚开始是一个空的电话本。你可以根据提示加入或删除纪录,还可以根据需要显示和查询电话号码\n");
   printf("按ENTER键继续\n");
   getch();
   system("cls");
   break;
  case 2:
   printf("你只要删除文件Friend.dat或者退出程序释放存储空间,就可以删除所有纪录了\n");
   printf("按ENTER键继续\n");
   getch();
   system("cls");
   break;
  case 3:
   printf("当然拉,加入信息不会改变原来的信息\n");
   printf("按ENTER键继续\n");
   getch();
   system("cls");
   break;
  case 4:
   printf("在查找和删除纪录时,应该把要找的朋友的全名写好,否则将无法显示和操作\n");
   printf("按ENTER键继续\n");
   getch();
   system("cls");
   break;
  default:
  case 5:
   printf("按ENTER键继续\n");
   break;
  }
 }while(nChoice!=5);
}
int VerifyDel_f() /*删除信息时要求予以确认*/
{
 char chYesNo;
 printf("你确定要删除吗?(Y/N)");
 scanf("%c",&chYesNo);
 if((chYesNo=='Y')||(chYesNo=='y'))
 {
  return(1);
 }
 else
 {
  return(0);
 }
}
void DelNode_f(Node *strpFront)/*删除结点*/
{
 if(strpCurrent==strpHead)
  DelHead_f();
 else
 {
  if(strpCurrent->next==NULL)
   DelEnd_f(strpFront);
  else
   DelMid_f(strpFront);
 }
}
void DelHead_f()  /*删除头结点*/
{
 strpCurrent=strpHead;
 if(strpHead->next!=NULL)
  strpHead=strpCurrent->next;
 else
  strpHead=NULL;
 free(strpCurrent);
}
void DelEnd_f(Node *strpFront) /*删除尾结点*/
{
 free(strpCurrent);
 strpFront->next=NULL;
 strpCurrent=strpHead;
}
void DelMid_f(Node *strpFront) /*删除链表中的结点*/
{
 strpFront->next=strpCurrent->next;
 free(strpCurrent);
 strpCurrent=strpHead;
}
void DelList_f()/*删除链表,释放空间*/
{
 Node *strpTemp;
 strpCurrent=strpHead;
 do
 {
  strpTemp=strpCurrent->next;
  free(strpCurrent);
  strpCurrent=strpTemp;
 }while(strpTemp!=NULL);
}
void Deln(char *szString)/*删除字符串后的回车符*/
{
 int nLength;
 nLength=strlen(szString);
 if(nLength>=2)
 {
  if(szString[nLength-1]=='\n')
   szString[nLength-1]='\0';
 }
}
void WriteFile_f()/*程序退出,将链表数据写回文件*/
{
 FILE *fpoutfile;
 if((fpoutfile=fopen("FRIENDS.DAT","w"))==NULL)
 {
  printf("File Error!\n");
  exit(0);
 }
 strpCurrent=strpHead;
 if(strpHead!=NULL)
 {
  do
  {
   fprintf(fpoutfile,"%s\n",strpCurrent->szName);
   fprintf(fpoutfile,"%s\n",strpCurrent->szPhoneNum);
   fprintf(fpoutfile,"%s\n",strpCurrent->szAddress);
   strpCurrent=strpCurrent->next;
  }while(strpCurrent!=NULL);
 }
 fprintf(fpoutfile,"END OF FILE");
 fclose(fpoutfile);/*关闭文件*/
}
void LoadFile_f()/*从数据文件FRIEND.DAT中读取数据重建链表*/
{
 Node *strpNew;
 FILE *fpinfile;/*输入文件指针*/
 int nEndLoop=0;
 if((fpinfile=fopen("FRIENDS.DAT","r"))==NULL)
 {
  printf("现在没有可用数据载入,链表为空\n");
 }
 else{
  do{
  strpNew=(Node *)malloc(sizeof(Node));
  if(strpNew!=NULL)
  {
   fgets(strpNew->szName,20,fpinfile);
   if((strcmp(strpNew->szName,"")!=0)&&(strcmp(strpNew->szName,"END OF FILE")!=0))
   {
    fgets(strpNew->szPhoneNum,15,fpinfile);
    fgets(strpNew->szAddress,15,fpinfile);
    Deln(strpNew->szName);
    Deln(strpNew->szPhoneNum);
    Deln(strpNew->szAddress);
    InsertNode_f(strpNew);
   }
   else
   {
    free(strpNew);
    nEndLoop=1;
   }
  }
  else
  {
   printf("WARNING:Memory error!\n");
   nEndLoop=1;
  }   
  }while(nEndLoop==0);
  fclose(fpinfile);
 }
}
 


我很厉害。。。
2008-05-28 19:23
快速回复:[求助]数据结构的课程设计!本人编程还不是最好,希望能求到详细的有解 ...
数据加载中...
 
   



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

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