⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 del.c

📁 大一时课程设计 通信录管理系统 可作为C课程设计的参考
💻 C
字号:
#include"yy.h"

NODE *del_by_name(NODE *head)
{
    NODE *p0,*p1,*p2;
    char name[16];
    if(head==NULL){printf("\n\tlist null!\n");
                   goto end;}
    p0=p1=head;
    printf("please input the name  and the adress will be del!!!\n\t");
    gets(name);
    while(strcmp(name,p1->name)!=0&&p1->next!=NULL)
        {p2=p1;
         p1=p1->next;
         }
    if(strcmp(name,p1->name)==0)
       {if(p1==head)head=p1->next;
        else{p0=p1;p2->next=p1->next;}

        printf("\nThe del address is:\n");
        printf("Name              Phone              Sex      Age      Birthday      Dormitory\n");
        printf("%-18s%-19s%-9c%-9d%-14s%s\n",p0->name,p0->phone,p0->sex,
                p0->age,p0->birthday,p0->dormitory);

        free(p0);
        n-=1;
        }
    else printf("%s not been found!\n",name);
    end:
    return head;
}

NODE *del_by_phone(NODE *head)
{
    NODE *p0,*p1,*p2;
    char phone[18];
    if(head==NULL){printf("\n\tlist null!\n");
           goto end2;}
    p0=p1=head;
    printf("please input the phone and the adress will be del!!!\n\t");
    gets(phone);
    while(strcmp(phone,p1->phone)!=0&&p1->next!=NULL)
        {p2=p1;
         p1=p1->next;
         }
    if(strcmp(phone,p1->phone)==0)
       {if(p1==head)head=p1->next;
        else{p0=p1;p2->next=p1->next;}

        printf("\nThe del address is:\n");
        printf("Name              Phone              Sex      Age      Birthday      Dormitory\n");
        printf("%-18s%-19s%-9c%-9d%-14s%s\n",p0->name,p0->phone,p0->sex,
                p0->age,p0->birthday,p0->dormitory);

        free(p0);
        n-=1;
        }
    else printf("%s not been found!\n",phone);
    end2:
    return head;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -