zoukankan      html  css  js  c++  java
  • c语言实现链表增、删、改、查及文件读写 && 链表实现程序

    一、链表实现增删改查

    1、链表定义

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<windows.h>
     4 #include<stdlib.h>
     5 #define maxn 10
     6 #define N 100005
     7 typedef struct  //歌曲信息
     8 {
     9     char author[20],style[20],name[20],belong[50];
    10     int is;
    11 } songs;
    12 typedef struct Sqlist //曲库链表
    13 {
    14     songs data;
    15     struct Sqlist *next;
    16 };
    17 typedef struct sang //点歌链表
    18 {
    19     songs data;
    20     struct sang *next;
    21 };
    22 struct sang *que,*str2,*s2,*s22;
    23 struct Sqlist *r,*str1,*s1,*s11;

    不要问为什么定义的都是指针类型结构体变量,因为一些变量定义指针类型,一些变量定义结构体类型。写着写着我就搞错了。。。。(是我的问题。。。)

    链表最重要就是它不需要一次性定义好多此类型结构体,只需要用到一个开一个空间就可以了

    2、初始化

    1 int Create()  //为各链表分配空间
    2 {
    3     r=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
    4     que=(struct sang *)malloc(sizeof(struct sang)*1);
    5     que->next=NULL;
    6     r->next=NULL;
    7     init();
    8     return 1;
    9 }

    这是两个链表,一个链表头为que、另一个链表头为r

    3、增加数据(以链表r来举例子)

     1 void Add()  //增添曲库内歌曲
     2 {
     3     system("cls");
     4     str1=r;
     5     while(str1->next!=NULL)
     6     {
     7         str1=str1->next;
     8     }
     9     s1=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
    10     printf("请按顺序输入以下内容
    ");
    11     printf("歌名:作者:曲风:语种:
    ");
    12     scanf("%s%s%s%s",s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    13     s1->data.is=0;
    14     s1->next=NULL;
    15     str1->next=s1;
    16     printf("添加成功
    ");
    17     system("pause");
    18 }

    这里要注意我们定义的s1是一个结构体指针,那么定义的时候是不会给他分配一个此结构体类型的空间的。换句话说,s1指向的地址是随机的。

    所以我们要给s1开一个此结构体类型的空间,把里面放满数据。然后加在链表尾部。

    注意:这个过程中链表的头节点r指向的地址可不能变。所以要用一个此结构体类型指针去遍历这个链表(我代码中用的是str1)

    4、删除

     1 void Delete()  //删除曲库内歌曲
     2 {
     3 
     4     int i,id;
     5     system("cls");
     6     printf("输入你要删除歌曲的编号
    ");
     7     scanf("%d",&id);
     8     printf("编号:歌名:作者:曲风:语种:
    ");
     9     str1=r;
    10     i=0;
    11     while(str1->next!=NULL)
    12     {
    13 
    14         if(i==id)
    15         {
    16             s1=str1->next;
    17             printf("%d %s %s %s %s
    ",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    18             printf("你确定要删除吗?确定输入1,否则输入0
    ");
    19             scanf("%d",&id);
    20             if(id)
    21             {
    22                 str1->next=s1->next;
    23                 free(s1);
    24             }
    25             break;
    26         }
    27         str1=str1->next;
    28         i++;
    29     }
    30     system("pause");
    31 }

    删除操作的进行需要找到两个位置

    1、要删除节点的上一个节点(代码中这个位置由str1来保存)

    2、要删除的这个节点 (代码中这个位置由s1来保存)

    然后让  (上一个节点指向下一个节点的指针)  指向   (要删除节点指向下一个节点的指针)

    理解一波。。。

    5、修改

     1 void Modify()  //修改曲库
     2 {
     3 
     4     int i,id;
     5     system("cls");
     6     printf("输入你要修改歌曲的编号
    ");
     7     scanf("%d",&id);
     8     printf("编号:歌名:作者:曲风:语种:
    ");
     9     str1=r;
    10     i=0;
    11     while(str1->next!=NULL)
    12     {
    13 
    14         if(i==id)
    15         {
    16             s1=str1->next;
    17             printf("%d %s %s %s %s
    ",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    18             printf("你确定要修改吗?确定输入1,否则输入0
    ");
    19             scanf("%d",&id);
    20             if(id)
    21             {
    22                 printf("依次输入歌名:作者:曲风:语种:
    ");
    23                 scanf("%s%s%s%s",&s1->data.name,&s1->data.author,&s1->data.style,s1->data.belong);
    24             }
    25             break;
    26         }
    27         str1=str1->next;
    28         i++;
    29     }
    30     system("pause");
    31 }

    修改就没什么讲的了,和删除操作代码大致上同

    6、查

     1 void Show()
     2 {
     3 
     4     int i;
     5     system("cls");
     6     printf("编号:歌名:作者:曲风:语种:
    ");
     7     str1=r;
     8     i=0;
     9     while(str1->next!=NULL)
    10     {
    11         str1=str1->next;
    12         printf("%d %s %s %s %s
    ",i++,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    13     }
    14 
    15     system("pause");
    16 }

    7、文件读写

    void init()  //导入文件内容
    {
        //第一个链表文件读取
        int i=0;
        char ch;
        FILE *fp=NULL;
        fp=fopen("songs.txt","a+");
        str1=r;
        s1=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
        while(fscanf(fp,"%s%s%s%s",s1->data.name,s1->data.author,s1->data.style,s1->data.belong)!=EOF)
        {
            s1->data.is=0;
            s1->next=NULL;
            str1->next=s1;
            str1=str1->next;
            s1=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
        }
        fclose(fp);
    
        //第二个链表文件读取
        fp=fopen("sangs.txt","a+");
        str2=que;
        s2=(struct sang *)malloc(sizeof(struct sang)*1);
        while(fscanf(fp,"%s%s%s%s",s2->data.name,s2->data.author,s2->data.style,s2->data.belong)!=EOF)
        {
            s2->data.is=0;
            s2->next=NULL;
            str2->next=s2;
            str2=str2->next;
            s2=(struct sang *)malloc(sizeof(struct sang)*1);
        }
        fclose(fp);
    }
    void Quit() //导出数据
    {
        //第一个链表文件写入
        int i;
        FILE *fp=NULL;
        system("cls");
        fp=fopen("songs.txt","w");
        str1=r;
        while(str1->next!=NULL)
        {
            str1=str1->next;
            fprintf(fp,"%s %s %s %s
    ",str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
        }
        fclose(fp);
    
        //第二个链表文件写入
        fp=fopen("sangs.txt","w");
        str2=que;
        while(str2->next!=NULL)
        {
            str2=str2->next;
            fprintf(fp,"%s %s %s %s
    ",str2->data.name,str2->data.author,str2->data.style,str2->data.belong);
        }
        fclose(fp);
        printf("文件保存成功,程序运行结束
    ");
        system("pause");
    }

    二、C语言编写程序(链表实现)

    (1)    录入歌曲语种分类信息,包括:中文,英文,日文,韩文,小语种;
    (2)    录入、修改歌曲信息,包括:歌曲编号,歌曲名,演唱者,曲风;删除歌曲;
    (3)    可以按歌曲语种分类信息显示歌曲信息。
    (4)    可以根据演唱者查询指定演唱者的所有歌曲信息;根据曲风查询指定曲风的所有歌曲信息。
    (5)    创建点歌列表。在曲库中按演唱者或曲风进行搜索,若查找成功将此歌曲添加到点歌链表中。
    (6)    优先指定歌曲。在点歌列表中选定优先歌曲,将该歌曲移至点歌列表中的指定位置。
    (7)    删除点歌列表中歌曲。
    4、完成所有功能并能适当添加或完善功能,且理解代码,90分
    (界面友好、系统健壮加1~10分不等)

    代码:

      1 #include<stdio.h>
      2 #include<string.h>
      3 #include<windows.h>
      4 #include<stdlib.h>
      5 #define maxn 10
      6 #define N 100005
      7 typedef struct  //结构体构造歌曲信息
      8 {
      9     char author[20],style[20],name[20],belong[50];
     10 } songs;
     11 typedef struct Sqlist //曲库链表
     12 {
     13     songs data;
     14     struct Sqlist *next;
     15 };
     16 typedef struct sang //点歌链表
     17 {
     18     songs data;
     19     struct sang *next;
     20 };
     21 struct sang *que,*str2,*s2;
     22 struct Sqlist *r,*str1,*s1;//que和r分别表示两个链表的头结点,str用来遍历两个头结点,s用来增加
     23 int admin_name[20],admin_password[20],len1; //管理员信息
     24 void init()//导入文件的内容
     25 {
     26     //int i = 0;
     27     //char ch;
     28     FILE *fp = NULL;
     29     fp = fopen("songs.txt","a+");
     30     str1 = r;//让str=头结点用来遍历
     31     s1 = (struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
     32     while(fscanf(fp,"%s%s%s%s",s1->data.name,s1->data.author,s1->data.style,s1->data.belong)!=EOF)
     33     {
     34         s1->next=NULL;
     35         str1->next = s1;
     36         str1 = str1->next;
     37         s1 = (struct Sqlist *)malloc(sizeof(struct Sqlist)*1);//遍历曲库,并且遍历出一个数据后在开空间
     38     }
     39     fclose(fp);
     40 //    fp = fopen("sangs.txt","a+");
     41 //    str2 = que;
     42 //    s2 = (struct sang *)malloc(sizeof(struct sang)*1);
     43 //    while(fscanf(fp,"%s%s%s%s",s2->data.name,s2->data.author,s2->data.style,s2->data.belong)!=EOF)
     44 //    {
     45 //        s2->next=NULL;
     46 //        str2->next = s2;
     47 //        str2 = str2->next;
     48 //        s2 = (struct sang *)malloc(sizeof(struct sang)*1);//遍历点歌区的内容
     49 //    }
     50 //    fclose(fp);
     51 }
     52 int space()  //为各链表分配空间
     53 {
     54     r=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
     55     que=(struct sang *)malloc(sizeof(struct sang)*1);
     56     que->next=NULL;
     57     r->next=NULL;
     58     init();
     59     return 1;
     60 }
     61 void Add()  //增添曲库内歌曲
     62 {
     63     int i;
     64     system("cls");
     65     str1=r;
     66     while(str1->next!=NULL)
     67     {
     68         str1=str1->next;//让str先成为链表最后一个数据;
     69     }
     70     s1=(struct Sqlist *)malloc(sizeof(struct Sqlist)*1);
     71     printf("输入1继续添加,输入0则返回初始界面
    ");
     72     scanf("%d",&i);
     73     if(i==0)
     74     {
     75          system("pause");
     76     }
     77     else
     78     {
     79         printf("请按顺序输入以下内容
    ");
     80         printf("歌名:作者:曲风:语种:
    ");
     81         scanf("%s%s%s%s",s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
     82         s1->next=NULL;
     83         str1->next=s1;
     84         printf("添加成功
    ");
     85         system("pause");
     86     }
     87 
     88 }
     89 void Delete()//删除操作对象为曲库
     90 {
     91     int i,id;
     92     system("cls");
     93     printf("请输出你要删除的歌曲的编号
    ");
     94     scanf("%d",&id);
     95     printf("编号:歌名:作者:曲风:语种:
    ");
     96     str1 = r;//遍历查找
     97     i = 0;
     98     while(str1->next!=NULL)
     99     {
    100             if(i==id)
    101             {
    102                 s1 = str1->next;
    103                 printf("%d %s %s %s
    ",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    104                 printf("你确定要删除吗? 确定删除请输入1,否则请输入0
    ");
    105                 scanf("%d",&id);
    106                 if(id)
    107                 {
    108                     str1->next = s1->next;//直接将要删除的节点的上一个next等于要删除节点的next
    109                     free(s1);
    110                 }
    111                 break;
    112             }
    113             str1 = str1->next;
    114             i++;
    115     }
    116     system("pause");
    117 }
    118 void Modify()//修改曲库中数据
    119 {
    120     int i,id;
    121     system("cls");
    122     printf("请输入你要修改的编号
    ");
    123     scanf("%d",&id);
    124     printf("编号:歌名:作者:曲风:语种:
    ");
    125     str1 = r;
    126     i = 0;//开始遍历
    127     while(str1->next!=NULL)
    128     {
    129         if(i == id)
    130         {
    131             s1 = str1->next;
    132             printf("%d %s %s %s %s
    ",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    133             printf("你确定要修改吗?确定请输入1,取消请输入0
    ");
    134             scanf("%d",&id);
    135             if(id)
    136             {
    137                 printf("请以此输入歌名:作者:曲风:语种:
    ");
    138                 scanf("%s%s%s%s",&s1->data.name,&s1->data.author,&s1->data.style,&s1->data.belong);
    139             }
    140             break;
    141         }
    142         str1 = str1->next;
    143         i++;
    144     }
    145     printf("修改成功!");
    146     system("pause");
    147 }
    148 void Select_style()//查找某种曲风的歌曲
    149 {
    150     int i,m;
    151     char s[50];
    152     system("cls");
    153     printf("输入1继续搜索,输入0则返回初始界面
    ");
    154     scanf("%d",&m);
    155     if(!m)
    156     {
    157         system("pause");
    158     }
    159     else{
    160         printf("请输入你要查找的曲风
    ");
    161     scanf("%s",s);
    162     printf("编号:歌名:作者:曲风:语种:
    ");
    163     str1 = r;
    164     i = 0;
    165     while(str1->next!=NULL)
    166     {
    167         str1 = str1 ->next;
    168         if(strcmp(s,str1->data.style)==0)//比较输入的曲风和该乐曲曲风是否相同
    169         {
    170            printf("%d %s %s %s %s
    ",i,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    171         }
    172         i++;
    173     }
    174     system("pause");
    175     }
    176 
    177 }
    178 void Select_name()//根据歌名来进行查找歌曲
    179 {
    180     int i,m;
    181     char s[50];
    182     system("cls");
    183     printf("输入1继续搜索,输入0则返回初始界面
    ");
    184     scanf("%d",&m);
    185     if(!m)
    186     {
    187         system("pause");
    188     }
    189     else
    190     {
    191         printf("请输入你要查找的歌曲名称
    ");
    192         scanf("%s",s);
    193         printf("编号:歌名:作者:曲风:语种:
    ");
    194         str1 = r;
    195         i = 0;
    196         while(str1->next!=NULL)
    197         {
    198             str1 = str1 ->next;
    199             if(strcmp(s,str1->data.name)==0)//比较输入的曲风和该乐曲曲风是否相同
    200             {
    201                 printf("%d %s %s %s %s
    ",i,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    202             }
    203             i++;
    204         }
    205         system("pause");
    206     }
    207 
    208 }
    209 void Select_author()//根据作者来查找歌曲
    210 {
    211     int i,m;
    212     char s[50];
    213     system("cls");
    214     printf("输入1继续搜索,输入0则返回初始界面
    ");
    215     scanf("%d",&m);
    216     if(!m)
    217     {
    218         system("pause");
    219     }
    220     else
    221     {
    222         printf("请输入你要查找的作者名字
    ");
    223         scanf("%s",s);
    224         printf("编号:歌名:作者:曲风:语种:
    ");
    225         str1 = r;
    226         i = 0;
    227         while(str1->next!=NULL)
    228         {
    229             str1 = str1 ->next;
    230             if(strcmp(s,str1->data.author)==0)//比较输入的曲风和该乐曲曲风是否相同
    231             {
    232                 printf("%d %s %s %s %s
    ",i,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    233             }
    234             i++;
    235         }
    236         system("pause");
    237     }
    238 
    239 }
    240 void Select_belong()
    241 {
    242     int i,m;
    243     char s[50];
    244     system("cls");
    245     printf("输入1继续搜索,输入0则返回初始界面
    ");
    246     scanf("%d",&m);
    247     if(!m)
    248     {
    249         system("pause");
    250     }
    251     else
    252     {
    253         printf("请输入你要查找的歌曲语种
    ");
    254         scanf("%s",s);
    255         printf("编号:歌名:作者:曲风:语种:
    ");
    256         str1 = r;
    257         i = 0;
    258         while(str1->next!=NULL)
    259         {
    260             str1 = str1 ->next;
    261             if(strcmp(s,str1->data.belong)==0)//比较输入的曲风和该乐曲曲风是否相同
    262             {
    263                 printf("%d %s %s %s %s
    ",i,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    264             }
    265             i++;
    266         }
    267         system("pause");
    268     }
    269 }
    270 void Show()//用来显示曲库中所有的歌曲数据
    271 {
    272     int i;
    273     system("cls");
    274     printf("编号:歌名:歌手:曲风:语种: 
    ");
    275     str1 = r;//准备头结点,开始遍历
    276     i = 0;//图书编号
    277     while(str1->next != NULL)
    278     {
    279         str1 = str1->next;
    280         printf("%d %s %s %s %s
    ",i++,str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    281     }
    282     system("pause");
    283 }
    284 void sing_list()
    285 {
    286     int i;
    287     system("cls");
    288     printf("编号:歌名:歌手:曲风:语种:
    ");
    289     str2 = que;
    290     i = 0;
    291     while(str2->next != NULL)
    292     {
    293         str2 = str2->next;
    294         printf("%d %s %s %s %s
    ",i++,str2->data.name,str2->data.author,str2->data.style,str2->data.belong);
    295     }
    296     system("pause");
    297 }
    298 void sing()//点歌
    299 {
    300     //先再曲库中搜索这首歌然后将数据取出来保存在点歌链表的文件夹里
    301     int i,id;
    302     system("cls");
    303     printf("输入你要点歌的歌曲的编号(会移动到点歌列表的表首)
    ");
    304     scanf("%d",&id);
    305     printf("编号:歌名:作者:曲风:语种:
    ");
    306     str1 = r;
    307     i = 0;//循环列表
    308     while(str1->next!=NULL)
    309     {
    310         if(i==id)
    311         {
    312             s1 = str1->next;
    313             printf("%d %s %s %s %s
    ",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong);
    314             printf("你确定要点这首歌么?确定请输入1,否则请输入0
    ");
    315             scanf("%d",&id);
    316             if(id)
    317             {
    318                 str2 = que->next;//点歌列表的头结点的next
    319                 s2 = (struct sang *)malloc(sizeof(struct sang)*1);//分配空间
    320                 strcpy(s2->data.name,s1->data.name);
    321                 strcpy(s2->data.author,s1->data.author);
    322                 strcpy(s2->data.style,s1->data.style);
    323                 strcpy(s2->data.belong,s1->data.belong);//将搜索到的歌曲的数据复制给s2
    324                 s2->next = str2;
    325                 que->next = s2; //将s2放在头结点的后面,即列表首位
    326                 printf("添加成功
    ");
    327             }
    328         }
    329         str1 = str1->next;
    330         i++;
    331     }
    332     system("pause");
    333 }
    334 void Del()//删除点歌链表中的歌曲
    335 {
    336     int i,id;
    337     system("cls");
    338     printf("编号:歌名:作者:曲风:语种: 
    ");
    339     str2 = que;
    340     i = 0;//准备遍历
    341     while(str2->next!=NULL)
    342     {
    343         str2 = str2->next;
    344         printf("%d %s %s %s %s
    ",i++,str2->data.name,str2->data.author,str2->data.style,str2->data.belong);
    345     }//输出所有的歌曲
    346     printf("请输入你想要删除歌曲的编号,输入-1则退出删除操作
    ");
    347     scanf("%d",&id);
    348     if(id==-1) return ;
    349     printf("编号:歌名:作者:曲风:语种:
    ");
    350     str2 = que;
    351     i = 0;
    352     while(str2->next!=NULL)
    353     {
    354         if(i==id)
    355         {
    356             s2 = str2->next;
    357             printf("%d %s %s %s %s
    ",i,s2->data.name,s2->data.author,s2->data.style,s2->data.belong);
    358             printf("你确定要删除这一首歌嘛?确定请输入1,否则请输入0
    ");
    359             scanf("%d",&id);
    360             if(id)
    361             {
    362                 str2->next = s2->next;//跳过中间这个点
    363                 free(s2);//清理空间
    364             }
    365             break;
    366         }
    367         str2 = str2->next;
    368         i++;
    369     }
    370     system("pause");
    371 }
    372 void Quit()//导出数据
    373 {
    374     int i;
    375     system("cls");
    376     FILE *fp = NULL;
    377     fp = fopen("songs.txt","w");
    378     str1 = r;
    379     while(str1->next!=NULL)
    380     {
    381         str1 = str1->next;
    382         fprintf(fp,"%s %s %s %s
    ",str1->data.name,str1->data.author,str1->data.style,str1->data.belong);
    383     }//将乐库中的数据写入文件中;
    384     fclose(fp);
    385 //    fp=fopen("sangs.txt","w");
    386 //    str2=que;
    387 //    while(str2->next!=NULL)
    388 //    {
    389 //        str2=str2->next;
    390 //        fprintf(fp,"%s %s %s %s
    ",str2->data.name,str2->data.author,str2->data.style,str2->data.belong);
    391 //    }
    392 //    fclose(fp);
    393     printf("文件保存成功,程序运行结束
    ");
    394     system("pause");
    395 }
    396 void admin_init()//初始化管理员信息
    397 {
    398     len1 = 1;
    399     admin_name[0] = 123456;
    400     admin_password[0] = 123456;
    401 }
    402 int login()//身份证注册
    403 {
    404     int i,x,na,pa;
    405     system("cls");
    406     printf("管理员登陆输出2,输入其他则以普通身份登录
    ");
    407     scanf("%d",&x);
    408     if(x==2)
    409     {
    410         printf("请输入登录id
    ");
    411         scanf("%d",&na);
    412         for(i =0;i<len1;i++)
    413         {
    414             if(admin_name[i]==na)
    415             {
    416                 printf("请输入密码
    ");
    417                 scanf("%d",&pa);
    418                 if(admin_password[i]==pa)
    419                 {
    420                     printf("登陆成功!");
    421                     system("pause");
    422                     return 2;//2是管理员登陆
    423                 }
    424                 else{
    425                     printf("密码错误
    ");
    426                     system("pause");
    427                     login();
    428                 }
    429             }
    430             else{
    431                 printf("该用户不存在!
    ");
    432                 system("pause");
    433                 login();
    434             }
    435         }
    436 
    437     }
    438     printf("登陆成功!
    ");
    439     return 0;
    440     system("pause");//0是普通用户登录
    441 }
    442 void Menu()
    443 {
    444     int flag,x,y=space();
    445     if(!y) return;
    446     admin_init();
    447     flag = login();
    448     while(1)
    449     {
    450         system("cls");
    451         if(flag==2)//如果是管理员身份
    452         {
    453             printf ("***********************************************************************************************************************************
    ");
    454             printf ("***********************************************************************************************************************************
    ");
    455             printf ("**                                                    ktv点歌管理员操作界面                                                      **
    ");
    456             printf ("***********************************************************************************************************************************
    ");
    457             printf ("***********************************************************************************************************************************
    ");
    458             printf ("***********************************************************************************************************************************
    ");
    459             printf ("***********************************************************************************************************************************
    ");
    460             printf ("**                                                丨                             丨                                              **
    ");
    461             printf ("**********************----------------------------丨[0]查看所有曲库              丨----------------------------********************
    ");
    462             printf ("**                                                丨                             丨                                              **
    ");
    463             printf ("**********************----------------------------丨[1]删除曲库歌曲              丨----------------------------********************
    ");
    464             printf ("**                                                丨                             丨                                              **
    ");
    465             printf ("**********************----------------------------丨[2]修改曲库歌曲              丨----------------------------********************
    ");
    466             printf ("**                                                丨                             丨                                              **
    ");
    467             printf ("**********************----------------------------丨[3]增加曲库歌曲              丨----------------------------********************
    ");
    468             printf ("**                                                丨                             丨                                              **
    ");
    469             printf ("**********************----------------------------丨[4]查找歌曲(歌名)            丨----------------------------********************
    ");
    470             printf ("**                                                丨                             丨                                              **
    ");
    471             printf ("**********************----------------------------丨[5]查找歌曲(演唱者)          丨----------------------------********************
    ");
    472             printf ("**                                                丨                             丨                                              **
    ");
    473             printf ("**********************----------------------------丨[6]查找歌曲(曲风)            丨----------------------------********************
    ");
    474             printf ("**                                                丨                             丨                                              **
    ");
    475             printf ("**********************----------------------------丨[7]查找歌曲(语种)            丨----------------------------********************
    ");
    476             printf ("**                                                丨                             丨                                              **
    ");
    477             printf ("**********************----------------------------丨[8]点歌                      丨----------------------------********************
    ");
    478             printf ("**                                                丨                             丨                                              **
    ");
    479             printf ("**********************----------------------------丨[9]删除点歌列表中歌曲        丨----------------------------********************
    ");
    480             printf ("**                                                丨                             丨                                              **
    ");
    481             printf ("**********************----------------------------丨[10]查看点歌列表             丨----------------------------********************
    ");
    482             printf ("**                                                丨                             丨                                              **
    ");
    483             printf ("**********************----------------------------丨[11]结束(将数据保存到文件中) 丨----------------------------********************
    ");
    484             printf ("**                                                丨                             丨                                              **
    ");
    485             printf ("**********************------------------------------------请输入相应数字---------------------------------------********************
    ");
    486             printf ("***********************************************************************************************************************************
    ");
    487             printf ("***********************************************************************************************************************************
    ");
    488             scanf("%d",&x);
    489             if(x==0)
    490             {
    491                 Show();
    492             }
    493             else if(x==1)
    494             {
    495                 Delete();
    496             }
    497             else if(x==2)
    498             {
    499                 Modify();
    500             }
    501             else if(x==3)
    502             {
    503                 Add();
    504             }
    505             else if(x==4)
    506             {
    507                 Select_name();
    508             }
    509             else if(x==5)
    510             {
    511                 Select_author();
    512             }
    513             else if(x==6)
    514             {
    515                 Select_style();
    516             }
    517             else if(x==7)
    518             {
    519                 Select_belong();
    520             }
    521             else if(x==8)
    522             {
    523                 sing();
    524             }
    525             else if(x==9)
    526             {
    527                 Del();
    528             }
    529             else if(x==10)
    530             {
    531                 sing_list();
    532             }
    533             else if(x==11)
    534             {
    535                 Quit();
    536                 return;
    537             }
    538         }
    539         else//如果是普通身份用另一个表
    540         {
    541            printf ("***********************************************************************************************************************************
    ");
    542             printf ("***********************************************************************************************************************************
    ");
    543             printf ("**                                                    ktv点歌普通用户操作界面                                                    **
    ");
    544             printf ("***********************************************************************************************************************************
    ");
    545             printf ("***********************************************************************************************************************************
    ");
    546             printf ("***********************************************************************************************************************************
    ");
    547             printf ("***********************************************************************************************************************************
    ");
    548             printf ("**                                                丨                             丨                                              **
    ");
    549             printf ("**********************----------------------------丨[0]查看所有曲库              丨----------------------------********************
    ");
    550             printf ("**                                                丨                             丨                                              **
    ");
    551             printf ("**********************----------------------------丨[1]查找歌曲(歌名)            丨----------------------------********************
    ");
    552             printf ("**                                                丨                             丨                                              **
    ");
    553             printf ("**********************----------------------------丨[2]查找歌曲(演唱者)          丨----------------------------********************
    ");
    554             printf ("**                                                丨                             丨                                              **
    ");
    555             printf ("**********************----------------------------丨[3]查找歌曲(曲风)            丨----------------------------********************
    ");
    556             printf ("**                                                丨                             丨                                              **
    ");
    557             printf ("**********************----------------------------丨[4]查找歌曲(语种)            丨----------------------------********************
    ");
    558             printf ("**                                                丨                             丨                                              **
    ");
    559             printf ("**********************----------------------------丨[5]点歌                      丨----------------------------********************
    ");
    560             printf ("**                                                丨                             丨                                              **
    ");
    561             printf ("**********************----------------------------丨[6]删除点歌列表中歌曲        丨----------------------------********************
    ");
    562             printf ("**                                                丨                             丨                                              **
    ");
    563             printf ("**********************----------------------------丨[7]结束                      丨----------------------------********************
    ");
    564             printf ("**                                                丨                             丨                                              **
    ");
    565             printf ("**********************------------------------------------请输入相应数字---------------------------------------********************
    ");
    566             printf ("***********************************************************************************************************************************
    ");
    567             printf ("***********************************************************************************************************************************
    ");
    568             scanf("%d",&x);
    569             if(x==0)
    570             {
    571                 Show();
    572             }
    573             else if(x==1)
    574             {
    575                 Select_name();
    576             }
    577             else if(x==2)
    578             {
    579                 Select_author();
    580             }
    581             else if(x==3)
    582             {
    583                 Select_style();
    584             }
    585             else if(x==4)
    586             {
    587                 Select_belong();
    588             }
    589             else if(x==5)
    590             {
    591                 sing();
    592             }
    593             else if(x==6)
    594             {
    595                 Del();
    596             }
    597             else if(x==7)
    598             {
    599                 sing_list();
    600             }
    601             else if(x==8)
    602             {
    603                 Quit();
    604                 return;
    605             }
    606         }
    607         }
    608     return;
    609 }
    610 int main()
    611 {
    612     Menu();
    613     return 0;
    614 }
  • 相关阅读:
    Leetcode 171. Excel Sheet Column Number
    Leetcode 206 Reverse Linked List
    Leetcode 147. Insertion Sort List
    小明一家人过桥
    Leetcode 125. Valid Palindrome
    Leetcode 237. Delete Node in a Linked List
    Leetcode 167 Two Sum II
    张老师的生日
    Leetcode 27. Remove Element
    Leetcode 283. Move Zeroes
  • 原文地址:https://www.cnblogs.com/kongbursi-2292702937/p/12075109.html
Copyright © 2011-2022 走看看