链表通讯录

    xiaoxiao2021-08-15  129

    /***************************************************** copyright (C), 2014-2015, Lighting Studio. Co.,     Ltd. File name: Author:Jerey_Jobs    Version:0.1    Date: Description: Funcion List: *****************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #define password 208140119 #define NAME_MAX 20 #define GENDER_MAX 10 #define STR_MAX 20 #define TEL_MAX 20 //链表结构 struct address {  long count;     char name[NAME_MAX];  char gender[GENDER_MAX];  int age;  char tel[TEL_MAX];  char strict[STR_MAX];  struct address *prior,*next; }; typedef struct address Data; typedef struct address * DATA; void create_link(DATA *head);        //创建链表 void create_newnode(DATA *newnode);        //创建新的节点 void is_malloc_ok(DATA *newnode);         //判断动态分配存储空间是否成功 //void address(DATA *head);        //对通讯录操作的函数 void menu_password(DATA *head);        //登录界面 void quit();        //退出通讯录 void menu(DATA *head);        //进入操作界面 void add(DATA *head);        //添加信息 void quit_real();        //真实退出 void display_all(DATA *head);        //显示全部信息 void find(DATA *head);        //查找信息界面 void find_count(DATA *head);        //按学号查找 void find_name(DATA *head);        //按姓名查找 void find_tel(DATA *head);        //按电话号码查找 void find_str(DATA *head);        //按地区查找 void delete(DATA *head);        //删除信息界面 void del_count(DATA *head);         //按学号删除 void del_name(DATA *head);         //按姓名删除 void del_tel(DATA *head);        //按电话号码删除 void del_str(DATA *head);        //按地区删除 void del(DATA temp,DATA *head);        //确认删除信息界面 void revise(DATA *head);        //修改信息界面 void rev(DATA temp,DATA *head);        //确认修改信息界面 void rev_sel(DATA temp,DATA *head);        //修改信息 void rev_count(DATA *head); void rev_name(DATA *head); void rev_tel(DATA *head); void rev_strict(DATA *head); int main() {  DATA head = NULL;  create_link(&head);        //创建链表  menu_password(&head);        //进入操作界面     return 0; } //创建链表 void create_link(DATA *head) {  create_newnode(head);  (*head)->prior = (*head)->next = (*head); } //创建新的节点 void create_newnode(DATA *newnode) {  *newnode = (DATA)malloc(sizeof(Data));  is_malloc_ok(newnode); } //判断动态分配存储空间是否成功 void is_malloc_ok(DATA *newnode) {  if(*newnode == NULL)  {   printf("malloc error !\n");   exit(-1);  } } //登录界面 void menu_password(DATA *head) {  long password_enter;  int select; // DATA temp; // temp = (*head)->next;  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");     printf("//                  南京工程学院班级通讯录                 \\\\\n");  printf("//                       Version 1.0                       \\\\\n");  printf("//                                                         \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       (1)登录                           \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       (2)退出                           \\\\\n");  printf("//                                                         \\\\\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");  printf("\n\n");  printf("请输入您的选择...\n");  scanf("%d",&select);  if(select == 1)  {   printf("请输入密码...\n");      scanf("%ld",&password_enter);      if(password == password_enter)      {       printf("密码正确!\n");       menu(head);    return;      }      else      {    printf("密码错误!\n");             menu_password(head);    return;      }  }  else if(select == 2)  {   quit();   return;  }  else  {   printf("您的输入有误!\n");   menu_password(head);   return;  } } //退出界面 void quit(DATA *head) {  int flag; // DATA temp // temp = *head;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**************************退出界面***********************\\\\\n");  printf("//                                                         \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       (1)确认退出                       \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       (2)返回登录界面                   \\\\\n");  printf("//                                                         \\\\\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");  printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&flag);  if(flag == 1)  {   quit_real();   return;  }  else if(flag == 2)  {   menu_password(head);   return;  }  else  {   printf("您的输入有误!\n");   quit(head);   return;  } } //真实退出 void quit_real() {  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");  printf("//                                                         \\\\\n");     printf("//                        谢谢使用!                       \\\\\n");  printf("//                                                         \\\\\n");     printf("//                        您已退出!                       \\\\\n");     printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  return; } //操作界面 void menu(DATA *head) {  int choose; // DATA temp; // temp = *head;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");     printf("//                    南京工程学院通讯录                   \\\\\n");  printf("//                       Version 1.0                       \\\\\n");  printf("//                                                         \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       (1)查询                           \\\\\n");  printf("//                       (2)添加信息                       \\\\\n");  printf("//                       (3)删除信息                       \\\\\n");  printf("//                       (4)修改信息                       \\\\\n");  printf("//                       (5)退出                           \\\\\n");  printf("//                                                         \\\\\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");  printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&choose);  switch(choose)  {   case 1 :find(head);break;   case 2 :add(head);break;   case 3 :delete(head);break;   case 4 :revise(head);break;   case 5 :quit(head);break;   default : {        printf("您的输入有误!\n");                       menu(head);       };break;  }  return; } //添加用户信息 void add(DATA *head) {  DATA temp;     DATA newnode = NULL;     temp = (*head)->next;     long count;  create_newnode(&newnode);  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************添加信息界面***********************\\\\\n");  printf("//                                                         \\\\\n");  printf("//                                                         \\\\\n");  printf("//                       请输入用户学号:");  scanf("%ld",&newnode->count);  count = newnode->count;  printf("//                       请输入用户姓名:");  scanf("%s",newnode->name);  printf("//                       请输入用户性别:");  scanf("%s",newnode->gender);  printf("//                       请输入用户年龄:");  scanf("%d",&newnode->age);  printf("//                       请输入用户电话:");  scanf("%s",newnode->tel);  printf("//                       请输入用户地区:");  scanf("%s",newnode->strict);  printf("//                                                         \\\\\n");  printf("//*********************************************************\\\\\n");  printf("//*********************************************************\\\\\n");  printf("\n");     if(temp == *head)        //链表为空,新节点插入到头节点之后的第一的位置  {   newnode->next = (*head)->next;   newnode->prior = (*head);   (*head)->next = newnode;   (*head)->prior = newnode;      printf("信息录入成功!\n");         menu(head);   return;  }  if(temp->next == *head)        //链表不为空,只有一个节点  {   if(temp->count > count)        //只有一个节点,对要插入的节点和第一个节点作比较   {    newnode->next = temp;    newnode->prior = (*head);    temp->prior = newnode;    (*head)->next = newnode;   }   else   {    newnode->next = temp->next;    newnode->prior = temp;    temp->next->prior = newnode;    temp->next = newnode;   }      printf("信息录入成功!\n");         menu(head);      return;  }  else  {                            //多个节点的情况   while(temp->count < count && temp->next != (*head))        //循环判断   {    temp = temp->next;   }   if(temp == (*head)->next)        //遇到第一个节点就退出循环,即新节点为当前链表最小   {    newnode->next = temp;    newnode->prior = (*head);    temp->prior = newnode;    (*head)->next = newnode;   }   else   {                        if(temp->next == (*head))        //查询到当前链表的尾节点    {     if(temp->count < count)        //新节点比尾节点大,即插入到尾节点之后     {         newnode->next = (*head);         newnode->prior = temp;         temp->next = newnode;            (*head)->prior = newnode;        }        else        {                         //新节点比尾节点小,插入到尾节点之前         newnode->next = temp;         newnode->prior = temp->prior;         temp->prior->next = newnode;      temp->prior = newnode;        }    }    else        //对于不到尾节点的新节点作处理    {     newnode->next = temp;     newnode->prior = temp->prior;     temp->prior->next = newnode;     temp->prior = newnode;    }   }      printf("信息录入成功!\n");         menu(head);   return;  } } //显示所有用户信息 void display_all(DATA *head) {  DATA temp;  temp = (*head)->next;  if(temp == *head)        //链表为空  {   printf("通讯录信息为空!\n");      find(head);   return;  }  else  {   while(temp != *head)        //链表不为空      {          printf("\n");          printf("//*********************************************************\\\\\n");          printf("//**********************显示信息界面***********************\\\\\n");          printf("//                                                         \\\\\n");          printf("//                                                         \\\\\n");          printf("//                       学号 : %d \n",temp->count);       printf("//                       姓名 : %s \n",temp->name);       printf("//                       性别 : %s \n",temp->gender);       printf("//                       年龄 : %d \n",temp->age);       printf("//                       电话号码 : %s \n",temp->tel);       printf("//                       地区 : %s \n",temp->strict);          printf("//                                                         \\\\\n");          printf("//*********************************************************\\\\\n");          printf("//*********************************************************\\\\\n");          printf("\n");       temp = temp->next;      }   printf("成功显示!\n");      find(head);   return;  } } //查找用户信息 void find(DATA *head) {  int select;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************查询信息界面***********************\\\\\n");     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("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&select);  switch(select)  {   case 1 :find_count(head);break;   case 2 :find_name(head);break;   case 3 :find_tel(head);break;   case 4 :find_str(head);break;   case 5 :display_all(head);break;   case 6 :menu(head);break;   default :{       printf("您的输入有误!请重新输入...\n");       menu(head);      };break;  }  return; } //学号查找用户信息 void find_count(DATA *head) {  DATA temp;  long count;  temp = (*head)->next;  printf("请输入您要查找信息的学号...\n");  scanf("%ld",&count);  printf("正在查询...\n");      if(temp == (*head))  {   printf("通讯录信息为空!\n");   find(head);   return;  }  else  {   while(temp->count != count && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要查找用户的信息!\n");    find(head);    return;   }   else   {          printf("\n");          printf("//*********************************************************\\\\\n");          printf("//**********************查询信息界面***********************\\\\\n");          printf("//                                                         \\\\\n");          printf("//                                                         \\\\\n");          printf("//                       学号 : %d \n",temp->count);       printf("//                       姓名 : %s \n",temp->name);       printf("//                       性别 : %s \n",temp->gender);       printf("//                       年龄 : %d \n",temp->age);       printf("//                       电话号码 : %s \n",temp->tel);       printf("//                       地区 : %s \n",temp->strict);          printf("//                                                         \\\\\n");          printf("//*********************************************************\\\\\n");          printf("//*********************************************************\\\\\n");          printf("\n");    find(head);    return;       }  } } //姓名查找用户信息 void find_name(DATA *head) {  DATA temp;  char name[NAME_MAX];  temp = (*head)->next;  printf("请输入您要查找信息的姓名...\n");  scanf("%s",name);  printf("正在查询...\n");      if(temp == (*head))  {   printf("通讯录信息为空!\n");   find(head);   return;  }  else  {   while( strcmp(temp->name,name) != 0&& temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要查找用户的信息!\n");       find(head);    return;   }   else   {    printf("\n");          printf("//*********************************************************\\\\\n");          printf("//**********************查询信息界面***********************\\\\\n");          printf("//                                                         \\\\\n");          printf("//                                                         \\\\\n");          printf("//                       学号 : %d \n",temp->count);       printf("//                       姓名 : %s \n",temp->name);       printf("//                       性别 : %s \n",temp->gender);       printf("//                       年龄 : %d \n",temp->age);       printf("//                       电话号码 : %s \n",temp->tel);       printf("//                       地区 : %s \n",temp->strict);          printf("//                                                         \\\\\n");          printf("//*********************************************************\\\\\n");          printf("//*********************************************************\\\\\n");          printf("\n");       find(head);    return;   }  } } //电话号码查找用户信息 void find_tel(DATA *head) {  DATA temp;  char tel[TEL_MAX];  temp = (*head)->next;  printf("请输入您要查找信息的电话号码...\n");  scanf("%s",tel);  printf("正在查询...\n");      if(temp == (*head))  {   printf("通讯录信息为空!\n");   find(head);   return;  }  else  {   while(strcmp(temp->tel,tel) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要查找用户的信息!\n");    find(head);    return;   }   else   {    printf("\n");          printf("//*********************************************************\\\\\n");          printf("//**********************查询信息界面***********************\\\\\n");          printf("//                                                         \\\\\n");          printf("//                                                         \\\\\n");          printf("//                       学号 : %d \n",temp->count);       printf("//                       姓名 : %s \n",temp->name);       printf("//                       性别 : %s \n",temp->gender);       printf("//                       年龄 : %d \n",temp->age);       printf("//                       电话号码 : %s \n",temp->tel);       printf("//                       地区 : %s \n",temp->strict);          printf("//                                                         \\\\\n");          printf("//*********************************************************\\\\\n");          printf("//*********************************************************\\\\\n");          printf("\n");    find(head);    return;   }  } } //地区查找用户信息 void find_str(DATA *head) {  DATA temp;  char strict[STR_MAX];  temp = (*head)->next;  printf("请输入您要查找用户信息的地区...\n");  scanf("%s",strict);  printf("正在查询...\n");      if(temp == (*head))  {   printf("通讯录信息为空!\n");   find(head);   return;  }  else  {   while( strcmp(temp->strict,strict) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要查找用户的信息!\n");    find(head);    return;   }   else   {    printf("\n");          printf("//*********************************************************\\\\\n");          printf("//**********************查询信息界面***********************\\\\\n");          printf("//                                                         \\\\\n");          printf("//                                                         \\\\\n");          printf("//                       学号 : %d \n",temp->count);       printf("//                       姓名 : %s \n",temp->name);       printf("//                       性别 : %s \n",temp->gender);       printf("//                       年龄 : %d \n",temp->age);       printf("//                       电话号码 : %s \n",temp->tel);       printf("//                       地区 : %s \n",temp->strict);          printf("//                                                         \\\\\n");          printf("//*********************************************************\\\\\n");          printf("\n");    find(head);    return;   }  } } //删除用户信息 void delete(DATA *head) {  int select;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************删除信息界面***********************\\\\\n");     printf("//                                                         \\\\\n");     printf("//                                                         \\\\\n");     printf("//                      (1)按学号查找删除                  \\\\\n");     printf("//                      (2)按姓名查找删除                  \\\\\n");     printf("//                      (3)按电话号码查找删除              \\\\\n");     printf("//                      (4)按地区查找删除                  \\\\\n");     printf("//                      (5)返回主菜单                      \\\\\n");  printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&select);  switch(select)  {   case 1 :del_count(head);break;   case 2 :del_name(head);break;   case 3 :del_tel(head);break;   case 4 :del_str(head);break;   case 5 :menu(head);break;   default :{       printf("您的输入有误!请重新输入...\n");       getchar();       menu(head);      };break;  }  return; } //学号删除用户信息 void del_count(DATA *head) {  DATA temp;  long count;  int select;  temp = (*head)->next;  printf("请输入您要删除信息的学号...\n");  scanf("%ld",&count);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   delete(head);   return;  }  else  {   while( temp->count != count && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要删除用户的信息!\n");    delete(head);    return;   }   else   {    del(temp,head);    return;   }  } } //删除信息界面 void del(DATA temp,DATA *head) {  int select;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************删除信息界面***********************\\\\\n");     printf("//                                                         \\\\\n");     printf("//                                                         \\\\\n");     printf("//                       学号 : %d \n",temp->count);  printf("//                       姓名 : %s \n",temp->name);  printf("//                       性别 : %s \n",temp->gender);  printf("//                       年龄 : %d \n",temp->age);  printf("//                       电话号码 : %s \n",temp->tel);  printf("//                       地区 : %s \n",temp->strict);  printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("您要删除的信息如上,是否真的要删除(删除 :1 or 返回 :2)\n");  scanf("%d",&select);  switch(select)  {   case 1 :{      temp->prior->next = temp->next;      temp->next->prior = temp->prior;      printf("该信息已删除!\n");      delete(head);      return;     };break;   case 2 :{      delete(head);     };break;   default :{       printf("您的输入有误!请重新输入...\n");       getchar();       del(temp,head);      };break;  }      return; } //姓名删除用户信息 void del_name(DATA *head) {  DATA temp;  char name[NAME_MAX];  int select;  temp = (*head)->next;  printf("请输入您要删除信息的姓名...\n");  scanf("%s",name);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   delete(head);   return;  }  else  {   while( strcmp(name,temp->name) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要删除用户的信息!\n");    delete(head);    return;   }   else   {    del(temp,head);    return;   }  } } //电话号码删除用户信息 void del_tel(DATA *head) {  DATA temp;  char tel[TEL_MAX];  int select;  temp = (*head)->next;  printf("请输入您要删除用户信息的电话号码...\n");  scanf("%s",tel);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   delete(head);   return;  }  else  {   while( strcmp(tel,temp->tel) != 0&& temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要删除用户的信息!\n");    delete(head);    return;   }   else   {    del(temp,head);    return;   }  } } //地区删除用户信息 void del_str(DATA *head) {  DATA temp;  char strict[STR_MAX];  int select;  temp = (*head)->next;  printf("请输入您要删除用户信息的地区...\n");  scanf("%s",strict);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   delete(head);   return;  }  else  {   while( strcmp(strict,temp->strict) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要删除用户的信息!\n");    delete(head);    return;   }   else   {    del(temp,head);    return;   }  } } //修改用户信息 void revise(DATA *head) {  int select;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************修改信息界面***********************\\\\\n");     printf("//                                                         \\\\\n");     printf("//                                                         \\\\\n");     printf("//                      (1)按学号查找修改                  \\\\\n");     printf("//                      (2)按姓名查找修改                  \\\\\n");     printf("//                      (3)按电话号码查找修改              \\\\\n");     printf("//                      (4)按地区查找修改                  \\\\\n");     printf("//                      (5)返回主菜单                      \\\\\n");  printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&select);  switch(select)  {   case 1 :rev_count(head);break;   case 2 :rev_name(head);break;   case 3 :rev_tel(head);break;   case 4 :rev_strict(head);break;   case 5 :menu(head);break;   default : {        printf("您的输入有误!请重新输入...\n");         revise(head);       };break;  } } //学号查找修改用户信息 void rev_count(DATA *head) {  DATA temp;  long count;  temp = (*head)->next;  printf("请输入您要修改用户信息的学号...\n");  scanf("%ld",&count);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   revise(head);   return;  }  else  {   while( temp->count != count && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要修改用户的信息!\n");    revise(head);    return;   }   else   {    rev(temp,head);    return;   }  } } //修改用户信息 void rev(DATA temp,DATA *head) {  int select;  printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************修改信息界面***********************\\\\\n");     printf("//                                                         \\\\\n");     printf("//                                                         \\\\\n");     printf("//                       学号 : %d \n",temp->count);  printf("//                       姓名 : %s \n",temp->name);  printf("//                       性别 : %s \n",temp->gender);  printf("//                       年龄 : %d \n",temp->age);  printf("//                       电话号码 : %s \n",temp->tel);  printf("//                       地区 : %s \n",temp->strict);  printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("您要修改的信息如上,是否真的要修改(修改 :1 or 返回 :2)\n");  scanf("%d",&select);  switch(select)  {   case 1 :{      rev_sel(temp,head);      return;     };break;   case 2 :{      revise(head);     };break;   default :{       printf("您的输入有误!请重新输入...\n");       getchar();       rev(temp,head);      };break;  }      return; } //选择修改什么选项 void rev_sel(DATA temp,DATA *head) {  int select;     printf("\n");  printf("//*********************************************************\\\\\n");  printf("//**********************修改信息界面***********************\\\\\n");     printf("//                                                         \\\\\n");     printf("//                                                         \\\\\n");     printf("//                      (1)修改学号                        \\\\\n");     printf("//                      (2)修改姓名                        \\\\\n");     printf("//                      (3)修改性别                        \\\\\n");     printf("//                      (4)修改年龄                        \\\\\n");     printf("//                      (5)修改电话号码                    \\\\\n");     printf("//                      (6)修改地区                        \\\\\n");     printf("//                      (7)返回主菜单                      \\\\\n");  printf("//                                                         \\\\\n");     printf("//*********************************************************\\\\\n");     printf("//*********************************************************\\\\\n");     printf("\n");  printf("请输入您的选择...\n");  scanf("%d",&select);  switch(select)  {   case 1 :{      printf("请输入您要修改的学号...\n");      scanf("%ld",&temp->count);      printf("修改成功!\n");                     revise(head);     };break;   case 2 :{      printf("请输入您要修改的姓名...\n");      scanf("%s",temp->name);      printf("修改成功!\n");      revise(head);     };break;   case 3 :{      printf("请输入您要修改的性别...\n");      scanf("%s",temp->gender);      printf("修改成功!\n");      revise(head);     };break;   case 4 :{      printf("请输入您要修改的年龄...\n");      scanf("%d",&temp->age);      printf("修改成功!\n");      revise(head);     };break;   case 5 :{      printf("请输入您要修改的电话号码...\n");      scanf("%s",temp->tel);      printf("修改成功!\n");      revise(head);     };break;   case 6 :{      printf("请输入您要修改的地区...\n");      scanf("%s",temp->strict);      printf("修改成功!\n");      revise(head);     };break;   case 7 :{      revise(head);     };break;   default :{       printf("您的输入有误!请重新输入...\n");                      rev_sel(temp,head);      };break;  }  return; } //姓名查找修改用户信息 void rev_name(DATA *head) {     DATA temp;  char name[NAME_MAX];  int select;  temp = (*head)->next;  printf("请输入您要修改用户信息的姓名...\n");  scanf("%s",name);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   revise(head);   return;  }  else  {   while( strcmp(name,temp->name) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要修改用户的信息!\n");    revise(head);    return;   }   else   {    rev(temp,head);    return;   }  } } //电话号码查找修改用户信息 void rev_tel(DATA *head) {     DATA temp;  char tel[TEL_MAX];  int select;  temp = (*head)->next;  printf("请输入您要修改用户信息的电话号码...\n");  scanf("%s",tel);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   revise(head);   return;  }  else  {   while( strcmp(tel,temp->tel) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要修改用户的信息!\n");    revise(head);    return;   }   else   {    rev(temp,head);    return;   }  } } //地区查找修改用户信息 void rev_strict(DATA *head) {     DATA temp;  char strict[STR_MAX];  int select;  temp = (*head)->next;  printf("请输入您要修改用户信息的地区...\n");  scanf("%s",strict);  printf("正在查询信息...\n");  if(temp == (*head))  {   printf("通讯录信息为空!\n");   revise(head);   return;  }  else  {   while( strcmp(strict,temp->strict) != 0 && temp != (*head))   {             temp = temp->next;   }   if(temp == (*head))   {    printf("没有您要修改用户的信息!\n");    revise(head);    return;   }   else   {    rev(temp,head);    return;   }  } }
    转载请注明原文地址: https://ju.6miu.com/read-676356.html

    最新回复(0)