一、鏈表實現增刪改查
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("請按順序輸入以下內容\n"); 11 printf("歌名:作者:曲風:語種:\n"); 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("添加成功\n"); 17 system("pause"); 18 }
這里要注意我們定義的s1是一個結構體指針,那么定義的時候是不會給他分配一個此結構體類型的空間的。換句話說,s1指向的地址是隨機的。
所以我們要給s1開一個此結構體類型的空間,把里面放滿數據。然后加在鏈表尾部。
注意:這個過程中鏈表的頭節點r指向的地址可不能變。所以要用一個此結構體類型指針去遍歷這個鏈表(我代碼中用的是str1)
4、刪除
1 void Delete() //刪除曲庫內歌曲 2 { 3 4 int i,id; 5 system("cls"); 6 printf("輸入你要刪除歌曲的編號\n"); 7 scanf("%d",&id); 8 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong); 18 printf("你確定要刪除嗎?確定輸入1,否則輸入0\n"); 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("輸入你要修改歌曲的編號\n"); 7 scanf("%d",&id); 8 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong); 18 printf("你確定要修改嗎?確定輸入1,否則輸入0\n"); 19 scanf("%d",&id); 20 if(id) 21 { 22 printf("依次輸入歌名:作者:曲風:語種:\n"); 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("編號:歌名:作者:曲風:語種:\n"); 7 str1=r; 8 i=0; 9 while(str1->next!=NULL) 10 { 11 str1=str1->next; 12 printf("%d %s %s %s %s\n",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\n",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\n",str2->data.name,str2->data.author,str2->data.style,str2->data.belong); } fclose(fp); printf("文件保存成功,程序運行結束\n"); 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則返回初始界面\n"); 72 scanf("%d",&i); 73 if(i==0) 74 { 75 system("pause"); 76 } 77 else 78 { 79 printf("請按順序輸入以下內容\n"); 80 printf("歌名:作者:曲風:語種:\n"); 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("添加成功\n"); 85 system("pause"); 86 } 87 88 } 89 void Delete()//刪除操作對象為曲庫 90 { 91 int i,id; 92 system("cls"); 93 printf("請輸出你要刪除的歌曲的編號\n"); 94 scanf("%d",&id); 95 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong); 104 printf("你確定要刪除嗎? 確定刪除請輸入1,否則請輸入0\n"); 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("請輸入你要修改的編號\n"); 123 scanf("%d",&id); 124 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong); 133 printf("你確定要修改嗎?確定請輸入1,取消請輸入0\n"); 134 scanf("%d",&id); 135 if(id) 136 { 137 printf("請以此輸入歌名:作者:曲風:語種:\n"); 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則返回初始界面\n"); 154 scanf("%d",&m); 155 if(!m) 156 { 157 system("pause"); 158 } 159 else{ 160 printf("請輸入你要查找的曲風\n"); 161 scanf("%s",s); 162 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",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則返回初始界面\n"); 184 scanf("%d",&m); 185 if(!m) 186 { 187 system("pause"); 188 } 189 else 190 { 191 printf("請輸入你要查找的歌曲名稱\n"); 192 scanf("%s",s); 193 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",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則返回初始界面\n"); 215 scanf("%d",&m); 216 if(!m) 217 { 218 system("pause"); 219 } 220 else 221 { 222 printf("請輸入你要查找的作者名字\n"); 223 scanf("%s",s); 224 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",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則返回初始界面\n"); 246 scanf("%d",&m); 247 if(!m) 248 { 249 system("pause"); 250 } 251 else 252 { 253 printf("請輸入你要查找的歌曲語種\n"); 254 scanf("%s",s); 255 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",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("編號:歌名:歌手:曲風:語種: \n"); 275 str1 = r;//准備頭結點,開始遍歷 276 i = 0;//圖書編號 277 while(str1->next != NULL) 278 { 279 str1 = str1->next; 280 printf("%d %s %s %s %s\n",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("編號:歌名:歌手:曲風:語種:\n"); 289 str2 = que; 290 i = 0; 291 while(str2->next != NULL) 292 { 293 str2 = str2->next; 294 printf("%d %s %s %s %s\n",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("輸入你要點歌的歌曲的編號(會移動到點歌列表的表首)\n"); 304 scanf("%d",&id); 305 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s1->data.name,s1->data.author,s1->data.style,s1->data.belong); 314 printf("你確定要點這首歌么?確定請輸入1,否則請輸入0\n"); 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("添加成功\n"); 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("編號:歌名:作者:曲風:語種: \n"); 339 str2 = que; 340 i = 0;//准備遍歷 341 while(str2->next!=NULL) 342 { 343 str2 = str2->next; 344 printf("%d %s %s %s %s\n",i++,str2->data.name,str2->data.author,str2->data.style,str2->data.belong); 345 }//輸出所有的歌曲 346 printf("請輸入你想要刪除歌曲的編號,輸入-1則退出刪除操作\n"); 347 scanf("%d",&id); 348 if(id==-1) return ; 349 printf("編號:歌名:作者:曲風:語種:\n"); 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\n",i,s2->data.name,s2->data.author,s2->data.style,s2->data.belong); 358 printf("你確定要刪除這一首歌嘛?確定請輸入1,否則請輸入0\n"); 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\n",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\n",str2->data.name,str2->data.author,str2->data.style,str2->data.belong); 391 // } 392 // fclose(fp); 393 printf("文件保存成功,程序運行結束\n"); 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,輸入其他則以普通身份登錄\n"); 407 scanf("%d",&x); 408 if(x==2) 409 { 410 printf("請輸入登錄id\n"); 411 scanf("%d",&na); 412 for(i =0;i<len1;i++) 413 { 414 if(admin_name[i]==na) 415 { 416 printf("請輸入密碼\n"); 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("密碼錯誤\n"); 426 system("pause"); 427 login(); 428 } 429 } 430 else{ 431 printf("該用戶不存在!\n"); 432 system("pause"); 433 login(); 434 } 435 } 436 437 } 438 printf("登陸成功!\n"); 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 ("***********************************************************************************************************************************\n"); 454 printf ("***********************************************************************************************************************************\n"); 455 printf ("** ktv點歌管理員操作界面 **\n"); 456 printf ("***********************************************************************************************************************************\n"); 457 printf ("***********************************************************************************************************************************\n"); 458 printf ("***********************************************************************************************************************************\n"); 459 printf ("***********************************************************************************************************************************\n"); 460 printf ("** 丨 丨 **\n"); 461 printf ("**********************----------------------------丨[0]查看所有曲庫 丨----------------------------********************\n"); 462 printf ("** 丨 丨 **\n"); 463 printf ("**********************----------------------------丨[1]刪除曲庫歌曲 丨----------------------------********************\n"); 464 printf ("** 丨 丨 **\n"); 465 printf ("**********************----------------------------丨[2]修改曲庫歌曲 丨----------------------------********************\n"); 466 printf ("** 丨 丨 **\n"); 467 printf ("**********************----------------------------丨[3]增加曲庫歌曲 丨----------------------------********************\n"); 468 printf ("** 丨 丨 **\n"); 469 printf ("**********************----------------------------丨[4]查找歌曲(歌名) 丨----------------------------********************\n"); 470 printf ("** 丨 丨 **\n"); 471 printf ("**********************----------------------------丨[5]查找歌曲(演唱者) 丨----------------------------********************\n"); 472 printf ("** 丨 丨 **\n"); 473 printf ("**********************----------------------------丨[6]查找歌曲(曲風) 丨----------------------------********************\n"); 474 printf ("** 丨 丨 **\n"); 475 printf ("**********************----------------------------丨[7]查找歌曲(語種) 丨----------------------------********************\n"); 476 printf ("** 丨 丨 **\n"); 477 printf ("**********************----------------------------丨[8]點歌 丨----------------------------********************\n"); 478 printf ("** 丨 丨 **\n"); 479 printf ("**********************----------------------------丨[9]刪除點歌列表中歌曲 丨----------------------------********************\n"); 480 printf ("** 丨 丨 **\n"); 481 printf ("**********************----------------------------丨[10]查看點歌列表 丨----------------------------********************\n"); 482 printf ("** 丨 丨 **\n"); 483 printf ("**********************----------------------------丨[11]結束(將數據保存到文件中) 丨----------------------------********************\n"); 484 printf ("** 丨 丨 **\n"); 485 printf ("**********************------------------------------------請輸入相應數字---------------------------------------********************\n"); 486 printf ("***********************************************************************************************************************************\n"); 487 printf ("***********************************************************************************************************************************\n"); 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 ("***********************************************************************************************************************************\n"); 542 printf ("***********************************************************************************************************************************\n"); 543 printf ("** ktv點歌普通用戶操作界面 **\n"); 544 printf ("***********************************************************************************************************************************\n"); 545 printf ("***********************************************************************************************************************************\n"); 546 printf ("***********************************************************************************************************************************\n"); 547 printf ("***********************************************************************************************************************************\n"); 548 printf ("** 丨 丨 **\n"); 549 printf ("**********************----------------------------丨[0]查看所有曲庫 丨----------------------------********************\n"); 550 printf ("** 丨 丨 **\n"); 551 printf ("**********************----------------------------丨[1]查找歌曲(歌名) 丨----------------------------********************\n"); 552 printf ("** 丨 丨 **\n"); 553 printf ("**********************----------------------------丨[2]查找歌曲(演唱者) 丨----------------------------********************\n"); 554 printf ("** 丨 丨 **\n"); 555 printf ("**********************----------------------------丨[3]查找歌曲(曲風) 丨----------------------------********************\n"); 556 printf ("** 丨 丨 **\n"); 557 printf ("**********************----------------------------丨[4]查找歌曲(語種) 丨----------------------------********************\n"); 558 printf ("** 丨 丨 **\n"); 559 printf ("**********************----------------------------丨[5]點歌 丨----------------------------********************\n"); 560 printf ("** 丨 丨 **\n"); 561 printf ("**********************----------------------------丨[6]刪除點歌列表中歌曲 丨----------------------------********************\n"); 562 printf ("** 丨 丨 **\n"); 563 printf ("**********************----------------------------丨[7]結束 丨----------------------------********************\n"); 564 printf ("** 丨 丨 **\n"); 565 printf ("**********************------------------------------------請輸入相應數字---------------------------------------********************\n"); 566 printf ("***********************************************************************************************************************************\n"); 567 printf ("***********************************************************************************************************************************\n"); 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 }