




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、高級語言程序設計課程設計說明書設計題目:歌曲信息管理系統(tǒng)設計目錄1、 設計題目·····································32、 主函數(shù)·····
2、183;·································43、 輸入模塊···············
3、······················44、 刪除模塊··························
4、3;··········55、 瀏覽模塊·····································66、 查找模塊
5、·····································67、 各被調函數(shù)···········
6、83;·······················78、 設計小結·························&
7、#183;···········89、 源程序代碼···································8歌曲信息管理系統(tǒng)設
8、計1、需求分析:用文件存儲信息,因而要提供文件的輸入輸出操作;可對歌曲信息進行輸入、刪除、瀏 覽,因而要提供文件的輸入、刪除和信息顯示操作;查詢歌曲信息要提供查找操作;實現(xiàn)按 作者分組顯示功能則要提供排序功能;另外要提供鍵盤式選擇菜單以實現(xiàn)功能選擇。 2、總體設計:整個管理系統(tǒng)可以被設計為數(shù)據(jù)輸入模塊、數(shù)據(jù)刪除模塊、信息瀏覽模塊、信息查詢模塊和信息分組顯示模塊。 3、詳細設計 數(shù)據(jù)結構采用結構體,建立歌曲信息結構體: Struct SongInfo Char name20; /歌曲名 Char author20; /作者 Char singer20; /演唱者 Char pub_date6;
9、/發(fā)行年月(yyyymm) SI; (1) 數(shù)據(jù)輸入模塊 把歌曲信息寫入文件。 (2) 數(shù)據(jù)刪除模塊 采用基本的查找算法,查找歌曲信息文件,如果是要刪除的歌曲,則舍棄改信息。否則 重新寫入文件。 (3) 信息瀏覽模塊 讀歌曲信息文件,顯示輸出。 (4) 信息查詢模塊 通過菜單選擇查詢字段:歌曲名 作者 演唱者。 然后采用基本查找算法在歌曲信息 文件中查找,如果找到,則輸出;否則輸出“對不起,沒有您要找的歌曲信息!。 ” (5) 信息分組顯示模塊 選擇按作者分組顯示歌曲信息,用 fread 或 fscanf 把歌曲信息文件中的信息讀取到臨時 變量中(臨時變量數(shù)據(jù)結構可以采用歌曲信息結構體數(shù)組)
10、,采用排序算法(冒泡、插入、 選擇等)把歌曲信息按照作者排序,然后輸出。 一: 詳細設計1 主函數(shù)主函數(shù)的設計提供數(shù)據(jù)輸入、數(shù)據(jù)處理和數(shù)據(jù)輸出以及各種函數(shù)的調用。其中各功能模塊用菜單方式選擇;另外,部分菜單也可以寫成函數(shù)。 程序 void main()void menu();void function1();void function2();void function3();void function4();menu();return;2 各功能模塊設計(1)輸入模塊信息輸入時直接按順序結構(如圖2)輸入:void input() char ch; n=0; if(fp=fopen("
11、;song.txt","a")=NULL) printf("can't open file song.txt"); exit(0); printf("Please input a record:"); for(n=0;n<=50;) printf("nrecord %d:n歌名:",n+1); gets(); printf("n時間:"); gets(songn.year); printf("n作者:"); gets(songn.a
12、uthor); printf("n歌手:"); gets(songn.singer); n+; printf("繼續(xù)輸入嗎? (y/n)n"); ch=getchar();getchar(); if(ch='n') break; fwrite(song,sizeof(song0),n,fp); fclose(fp); 2 刪除模塊:用戶輸入要刪除的信息,如輸入歌曲名 ,根據(jù)歌曲名找到其他記錄并刪除。程序/*刪除模塊*/void del() int m,k=0;long a;char namekey8;printf("n請輸入您要
13、刪除的歌曲名:");scanf("%s",namekey);if(fp=fopen("song.txt","r+")=NULL) printf("n不能打開該文件!");exit(0);while(!feof(fp)a=ftell(fp); fscanf(fp,"%6s %5s %5s %10sn",,songn.year,songn.author,songn.singer);if(strcmp(namekey,)=0)k=1;break;if(
14、k=1)printf("n已查到,記錄為");printf("n%6s %5s %5s %10sn",,songn.year,songn.author,songn.singer);printf("n確實要刪除,按1;不刪除,按0:");scanf("%d",&m);if(m=1)fseek(fp,a,0);fprintf(fp,"%s %s %s %sn"," " ," "," "," "
15、);elseprintf("n對不起,查無此人。");fclose(fp); 3·瀏覽模塊:在用戶按下菜單后直接顯示出所有歌曲信息。void xianshi() n=0; if(fp=fopen("song.txt","rb")=NULL) printf("can't open the file song.txt"); exit(0); printf(" 歌名t 作者t 歌手 時間 n"); while(fread(&songn,sizeof(songn),1,fp)=
16、1) printf("%6s %5s %10s %5sn",,songn.author,songn.singer,songn.year); n+; fclose(fp);4·查找模塊:用戶輸入要查找的歌曲名或歌曲的任意信息,按菜單鍵。void searchname() int a=0; char ch; n=0; if(fp=fopen("song.txt","rb")=NULL) printf("can not open the file.n "); exit(0); while(f
17、read(&songn,sizeof(songn),1,fp)=1) n+; a=n; printf("用什么方式查詢?n"); printf("1.歌名 2.時間 3.歌手n"); ch=getchar();getchar(); switch(ch) case '1': printf(" 輸入你要查的歌名:n"); gets(numstr); for(n=0;n<a;) if(!strcmp(numstr,) break; n+; break; case '2': p
18、rintf("輸入你要查的歌曲時間n"); gets(numstr); for(n=0;n<a;) if(atol(numstr)=songn.year) break; n+; break; case '3': printf("輸入你要查的歌手n"); gets(numstr); for(n=0;n<a;) if(!strcmp(numstr,songn.singer) break; n+; break; printf(" 歌名 作者 歌手 時間 n"); printf("%6s %5s %5s
19、%10sn",,songn.year,songn.author,songn.singer); fclose(fp); 6 各種被調函數(shù)(1)insert函數(shù):數(shù)據(jù)的插入,用于個人的信息的補錄,包括姓名、工作單位、電話號碼和email地址。(2)del函數(shù):用于通訊錄中個人信息的刪除。(3)change函數(shù):用于通訊錄中個人信息的修改,輸入人名,對人名所對應的機構體內容進行修改(包括姓名、工作單位、電話號碼和email信息)。(4)searchname函數(shù):用于輸入姓名查找個人信息。如果通訊錄中沒有此人信息,顯示“查無此人!”。(5)searchnum函數(shù):用于輸入
20、電話號碼查詢個人信息。如果通訊錄中沒此人信息,顯示“查無此人!”。(6)show函數(shù):用于個人全部信息的顯示。(7)income函數(shù):用于所有原始個人信息的錄入(包括姓名、電話號碼、工作單位和email地址)。設計小結:本程序大體參考與網(wǎng)上信息,說實話,這程序我無法完成,但又必須做,即使不會或者做不完美,但是也要盡力去做,做這個程序是要我們能夠使用所學的內容,這次設計,讓我重新掌握了C語言,而且還得到了用C語言解決實際問題的寶貴經(jīng)驗,也從中學到了很多東西。讓我懂得了做什么事都要有耐心,要有對什么事都認真仔細的品質,讓我學會了很多以前不懂的東西,使我更加意識到實踐的重要性!三 :原程序#incl
21、ude <stdio.h>#include <stdlib.h>#include <malloc.h>#include <string.h>int i=0;struct system char author20;char singer20;char time20;char name20; dan100;void enter()int j;char c2;FILE *fp; if(fp=fopen("data.txt","w")=NULL)printf("Can not open the file!
22、n");exit(0);for(j=0;j<i;j+) fwrite(&danj,sizeof(struct system),1,fp); while(1)printf("Please input the author:n");scanf("%s",dani.author);printf("Please input the song's name:n");scanf("%s",);printf("Please input the singer:n"
23、;);scanf("%s",dani.singer);printf("Please input the outday:n");scanf("%s",dani.time);if(fwrite(&dani+,sizeof(struct system),1,fp)!=1)printf("File write errorn");else printf("Successful!n");printf("Is there any more?( Yesy/Non) n");scanf
24、("%s",c);if(strcmp(c,"n")=0)break; fclose(fp);void delete() int j,v,c;char w20; FILE *fp;printf("Please input the song'name which you want to delete:");scanf("%s",w); fp=fopen("data.txt","rb"); for(j=0;j<100;j+) if(fread(&danj,si
25、zeof(struct system),1,fp)!=1) break;v=j;for(j=0;j<v;j+) if(strcmp(w,)=0)c=j; fclose(fp);fp=fopen("data.txt","wb"); for(j=0;j<v;j+) if(j!=c) fwrite(&danj,sizeof(struct system),1,fp); fclose(fp);printf("Delete OK!n");i-;void browse() int j; FILE *fp; fp
26、=fopen("data.txt","rb"); for(j=0;j<100;j+) if(fread(&danj,sizeof(struct system),1,fp)=1)printf("Name:%sn",);printf("Author:%sn",danj.author);printf("Singer:%sn",danj.singer);printf("Outday:%sn",danj.time);printf("-n&quo
27、t;);else break; fclose(fp);void search() int flag,j,x;char w20;FILE *fp;char v20; printf("(1)By authorn"); printf("(2)By singern");printf("(3)By namen");printf("Please choose which you want to search:n");scanf("%d",&x); if(x=3) flag=0;printf(&quo
28、t;Please input the song's name:"); scanf("%s",&w); fp=fopen("data.txt","rb"); for(j=0;j<100;j+) if(fread(&danj,sizeof(struct system),1,fp)!=1) break; if(strcmp(,w)=0) printf("Name:%sn",);printf("Author:%sn",danj.
29、author);printf("Singer:%sn",danj.singer);printf("Outday:%sn",danj.time);printf("-n");flag=1; if(flag=0)printf("Cannot find the song!n"); fclose(fp);else if(x=2) flag=0;printf("Please input the singer:"); scanf("%s",&v); fp=fopen("d
30、ata.txt","rb"); for(j=0;j<100;j+) if(fread(&danj,sizeof(struct system),1,fp)!=1) break; if(strcmp(danj.singer,v)=0) printf("Name:%sn",);printf("Author:%sn",danj.author);printf("Singer:%sn",danj.singer);printf("Outday:%sn",danj.time);printf("-n");flag=1; if(flag=0)printf("Cannot find the song!n"); fclose(fp); else if(x=1) flag=0;printf("Please inp
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權】 ISO/TR 23652:2024 EN Nanotechnologies - Considerations for radioisotope labelling methods of nanomaterials for performance evaluation
- 【正版授權】 ISO 4064-1:2024 EN Water meters for cold potable water and hot water - Part 1: Metrological and technical requirements
- 包露與配偶2025年度離婚經(jīng)濟補償及贍養(yǎng)費協(xié)議
- 2025年度太陽能光伏發(fā)電系統(tǒng)設計與施工總承包協(xié)議
- 2025年度環(huán)境安全監(jiān)測與治理服務合同協(xié)議
- 班級體育活動的組織與安排計劃
- 庫存分析對倉庫決策的支持計劃
- 急診呼吸機使用規(guī)范與管理計劃
- 提高團隊創(chuàng)新力的工作總結計劃
- 2025年建筑鋁擠壓材項目建議書
- 2025年度度假村景觀設計及施工一體化合同
- 2025年中國東方電氣集團有限公司招聘筆試參考題庫含答案解析
- 2024-2025學年云南省昆明市盤龍區(qū)三年級(上)期末數(shù)學試卷(含答案)
- 物業(yè)公司行政人事部職責
- 模具檢測知識培訓
- 醫(yī)療健康行業(yè)保密免責協(xié)議書
- 《設計思維與方法》課件
- 2025年七年級下冊道德與法治主要知識點
- 第一課走進人工智能 說課稿 2023-2024學年浙教版(2023)初中信息技術八年級下冊
- 第25章 概率初步(2)-2024-2025學年數(shù)學人教版九年級上冊(含答案解析)
- 2025年交通運輸部長江口航道管理局招聘4人歷年高頻重點提升(共500題)附帶答案詳解
評論
0/150
提交評論