七、删除
五、本次课程设计的心得体会
该程序的新颖性在于结构体和文件的使用上,这两个章节都是老师在课堂上没有讲过的,因此也是在不断的实践,不断的调试中实现的。结构体和文本的使用保证了这个程序可以存储大量的信息。该程序具备一个基本的员工通讯录所需要的功能。我不仅巩固《C语言程序设计》课程学习的内容,掌握设计的基本方法,强化上机动手能力,还进一步掌握以下了知识:数据类型、分支控制、循环控制、函数的定义及调用、结构体及数组、指针、文件操作、编译预处理等;通过课程设计,掌握了程序的局部测试、调试方法,建立程序系统调试、测试的基本概念和思想,学会较大程序的系统测试和调试方法。
团队精神不可少,分工合作也是必须的,身为组长就要以身作则,带领好小组,做好各项工作。在开始,对本组人员进行整理,分析其特点,再分配任务,然后进行综合应用,最后对所需资料及要编的程序进行整理得出最后程序。
通过这次课程设计使我们懂得了理论与实际相结合是很重要的,只有理论知识是远远不够的,只有把所学的理论知识与实践相结合起来,从理论中得出结论,才能真正为社会服务,从而提高自己的实际动手能力和独立思考的能力。
六、附录
【源程序】
#include
#include
#include
#define LEN sizeof(struct address_list) //计算字节// int n;
struct address_list {
char name[30]; //名字 char work[50]; //单位 char handset[30]; //手机
char phone[30]; //固定电话 char email[30]; //电子邮件 char address[30]; //通讯地址 char QQ[20]; //QQ
int t; //类别标记 char fenlei[30]; //分类 struct address_list *next; };
struct address_list *shifang(struct address_list *head); // 释放内存函数声明 //创建函数,不带头结点的链表 struct address_list *creat(void) {
struct address_list *head,*p1,*p2; char name[20];
n=0;
p1=(struct address_list *)malloc(LEN); p2=p1; //强制内存转换
printf(\请输入通讯录的内容!\\n姓名输入为0时表示创建完毕!\\n\ printf(\请输入姓名:\ gets(name);
if(strcmp(name,\ {
strcpy(p1->name,name);
printf(\请输入单位:\ gets(p1->work); printf(\请输入手机:\ gets(p1->handset); printf(\请输入固定电话:\ printf(\请输入电子邮件:\ printf(\请输入QQ号码:\
printf(\请输入通讯地址:\ gets(p1->address);
printf(\请输入分类(1.同事 2.朋友 3.同学 4.家人 5.其他):\ switch(p1->t) {
case 1:strcpy(p1->fenlei,\同事\ case 2:strcpy(p1->fenlei,\朋友\ case 3:strcpy(p1->fenlei,\同学\ case 4:strcpy(p1->fenlei,\家人\ case 5:strcpy(p1->fenlei,\其他\ }
head=NULL; while(1) {
n=n+1; //记录通讯录人数个数 if(n==1)
head=p1; else
p2->next=p1; p2=p1;
printf(\请输入姓名:\ scanf(\ if(strcmp(name,\ {
break; } else {
p1=(struct address_list *)malloc(LEN); strcpy(p1->name,name);
printf(\请输入单位:\ scanf(\ printf(\请输入手机:\ scanf(\ printf(\请输入固定电话:\ printf(\请输入电子邮件:\
printf(\请输入QQ号码:\
printf(\请输入通讯地址:\ scanf(\
printf(\请输入分类(1.同事 2.朋友 3.同学 4.家人 5.其他):\
scanf(\
switch(p1->t) {
case 1:strcpy(p1->fenlei,\同事\ case 2:strcpy(p1->fenlei,\朋友\ case 3:strcpy(p1->fenlei,\同学\ case 4:strcpy(p1->fenlei,\家人\ case 5:strcpy(p1->fenlei,\其他\ } } }
p2->next=NULL; return head; } else
return 0; }
//输出函数
void print(struct address_list *head) {
struct address_list *p; if(head!=NULL) {
p=head;
printf(\本通讯录现在共有%d人:\\n\
printf(\姓名-------单位--------手机-------固定电话-------Email--------QQ--------通讯地址--------类别--\\n\
printf(\ do {
printf(\ \ printf(\ \ printf(\ \ printf(\ \ printf(\ \ printf(\ \ printf(\ \ printf(\ \\n\ p=p->next; }while(p!=NULL);
printf(\ } else
printf(\通讯录为空,无法输出!\\n\}
//增加函数
struct address_list *insert(struct address_list *head) {
struct address_list *p0,*p1,*p2; char name[20]; p1=head;
printf(\请输入增加的内容:\\n\ printf(\请输入姓名:\ if(strcmp(name,\ {
printf(\姓名不能为0,增加失败!\\n\ return(head); } else {
p0=(struct address_list *)malloc(LEN); strcpy(p0->name,name);
printf(\请输入单位:\ gets(p0->work); printf(\请输入手机:\ gets(p0->handset); printf(\请输入固定电话:\ printf(\请输入电子邮件:\ printf(\请输入QQ号码:\
printf(\请输入通讯地址:\ gets(p0->address);
printf(\请输入分类(1.同事 2.朋友 3.同学 4.家人 5.其他):\ switch(p0->t) {
case 1:strcpy(p0->fenlei,\同事\ case 2:strcpy(p0->fenlei,\朋友\ case 3:strcpy(p0->fenlei,\同学\ case 4:strcpy(p0->fenlei,\家人\ case 5:strcpy(p0->fenlei,\其他\ } n=n+1;
if(head==NULL) {
head=p0;
p0->next=NULL; return head; } else {
while(strcmp(p0->name,p1->name)>0&&(p1->next!=NULL)) {
p2=p1;
相关推荐: