c课程设计电话簿管理内容摘要:

p_ptr = head_ptr。 // 使 temp_ptr 指向当前的链首 new_rec_ptrnext = temp_ptr。 // 使欲插入节点的 next 指针指 向当前链首 temp_ptrprev=new_rec_ptr。 //使 temp_ptr 指针的前向指针指向新插入节点 head_ptr = new_rec_ptr。 // 再使欲插入节点成为新的链首 ,即成功插入新节点至链表首 } // 使被 new_rec_ptr 所指的节点成为链尾的函数 // 用来处理插入时的一类特殊情况 . void friend_node::add_node_to_end(friend_node *new_rec_ptr) { new_rec_ptrnext = NULL。 // 使欲插入节点的 next 指针指向 NULL. new_rec_ptrprev=tail_ptr。 move_current_to_end()。 // 调用 move_current_to_end()函数使 current_ptr指向链表尾 current_ptrnext = new_rec_ptr。 // 使 current_ptr 的 next 指向欲插入节点 ,从而使欲插入节点成为链尾 } // 使 current_ptr 指向链表尾的函数 void friend_node::move_current_to_end() { current_ptr = head_ptr。 // 把头指针的地址给 current_ptr while(current_ptrnext != NULL) { // 遍历链表直至到达链表尾 current_ptr = current_ptrnext。 } } // 显示整个链表 void friend_node::display_list() { char fullname[36]。 // 定义一个字符型数组 ,用来存放姓名 int n。 //每屏显示的纪录数 current_ptr = head_ptr。 // 把头指针的地址给 current_ptr,从而实现遍历链表 if(current_ptr != NULL) { cout endl。 cout 请输入每屏显示的纪录数 :。 cin n。 cout 姓 名 电话号码 \n。 cout 录 入 时 间 : nYear / nMonth / nDay / nHour:nMinuteendl。 //输出时间 cout \n。 do { int i=1。 while (i=namp。 amp。 current_ptr != NULL) { strcpy(fullname,)。 // 首先清空 fullname strcat(fullname, current_ptrlast_name)。 // 以下 3 行均为字符串处理函数 ,实现拼接 strcat(fullname, )。 // 拼接为 last_name first_name strcat(fullname, current_ptrfirst_name)。 (ios::left)。 //设置左对齐 cout setw(10)fullname。 (ios::left)。 //取消设置左对齐 (ios::right)。 //设置右对齐 cout setw(20) current_ptrphone_num endl。 current_ptr = current_ptrnext。 // 使 current_ptr 指向下一个结点 . cout endl。 i++。 } cout 按 Enter 继续 \n。 (pause)。 (1,pause)。 } while(current_ptr != NULL)。 // 循环直到链表尾 system(cls)。 } else // 若链表为空 ,显示此信息 { cout \n 没有记录可显示 \n。 } } void friend_node::jqsearch_by_name() //精确查找某一记录 { system(cls)。 char last_name_string[20]。 // 定义一字符型数组用来存放 last_name current_ptr = head_ptr。 // 移 current_ptr 指针至链首 (20,39。 \n39。 )。 cout \n 请输入你想查询 (或修改)者的姓 :。 (last_name_string,20)。 //输入姓并保存在 last_name_string if(current_ptr != NULL) // 如果 current_ptr 不为空 ,查找开始 { while( current_ptr!=NULL ) { if( strcmp(current_ptrlast_name, last_name_string) == 0) { temp_ptr=current_ptr。 cout \n 找到信息 \n。 cout endl。 cout \n。 cout 姓名 电话号码 \n。 cout \n。 (ios::left)。 (ios::right)。 cout current_ptrlast_name 39。 39。 current_ptrfirst_name。 cout setw(36) current_ptrphone_num endl。 } current_ptr = current_ptrnext。 } current_ptr=temp_ptr。 } else { cout 没有找到记录 \n。 cout 按回车键继续 \n。 (pause)。 system(cls)。 } } void friend_node::search_by_name() //精确 查找某一记录 { system(cls)。 char last_name_string[20]。 // 定义一字符型数组用来存放 last_name char first_name_string[20]。 // 定义一字符型数组用来存放 first_name current_ptr = head_ptr。 // 移 current_ptr 指针至链首 (20,39。 \n39。 )。 cout \n 请输入你想查询 (或修改)者的姓 :。 (last_name_string,20)。 //输入姓并保存在 last_name_string (20,39。 \n39。 )。 cout \n 请输入你想查询 (或修改)者的名 :。 (first_name_string,20)。 //输入名并保存在 first_name_string if(current_ptr != NULL) // 如果 current_ptr 不为空 ,查找开始 { while( current_ptr!=NULL ) { if( strcmp(current_ptrfirst_name, first_name_string) == 0 amp。 amp。 strcmp(current_ptrlast_name, last_name_string) == 0) { temp_ptr=current_ptr。 cout \n 找到信息 \n。 cout endl。 cout \n。 cout 姓名 电话号码 \n。 cout。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。