版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第二組 建立藏譜檔案系統組員名單:9621112劉冠宏、9572142簡妗庭、9548038陳郁芬一、 系統功能,輸入及輸出資料由於社團藏譜數量非常龐大,又經常需要找譜,因此需要一個完整的藏譜資料建立系統。這個系統的功能在於儲存藏譜資料清單,並且方便於資料的增加、刪減、移動、搜尋等功能。系統有以下功能:add n:加一筆編號為 n 的資料。elete n:刪除編號為 n 的資料。update n:更改編號為 n 的資料。move a b:將編號為 a 的資料移動到序號 b 。sort $:列出樂譜名稱字首為 $ 的譜(中文: # ,其他: )。 search S:搜尋檔案中樂譜名稱含有 S 的
2、資料。list:顯示所有已存資料。save:將資料存到原始檔案。out $ FILE:將樂譜名稱字首為 $ 的項目輸出至檔案 FILE。print FILE:將所有項目輸出至檔案 FILE。 clear:清除畫面。 logout:登出系統。 quit:離開程式。1. 輸入的資料編號樂譜名稱作曲家類型等級建立日期Linked list(尋找有al的字元)1aladdin suitcarl nielsenall32009/01/1432Bella baroccojames barnesall22009/01/1443alvamar overturejames barnesall52009/01/1
3、454bazing graceearly americanAll22009/01/14NULL5american patrolf. w.meachamAll42009/01/14NULL2.輸出的資料依照指定而不同,可儲存本次執行結果,也可列印出檔案清單。3.基本假設與說明使用此系統的人會能夠按照正常程序執行,不故意輸入奇怪的指令來讓程式發生錯誤。並且需要在little endian的CPU上執行。(主要是因為binary file的因素,所以都在big endian的也可以)目前設定檔案資料最多100筆,因此只能輸入編號1100,且譜名及作者最多輸入20字元,類型最多輸入10字元。(多出來的
4、不會讀入)二、 應用層面說明可用於各類檔案清單的建立。三、 資料結構說明l 編號l 樂譜名稱(最長為20字元)l 作曲家(最長為20字元)l 類型(最長為10字元)l 等級l 建立日期欄位意義欄位名稱編號record樂譜名稱scoreName20作曲家authorName20類型type10等級level建立日期date3到下一筆相同struct的資料的指標score *nextPtr四、 程式剖析1. 主程式main()l 說明:主要程式l 輸入參數:無l 傳回值:無l 流程圖:l 程式碼:int main() char AtoZ, YorN; /AtoZ 是記錄譜名字首的,YorN 是記錄
5、輸入對錯的 char Instruct10, score30; /Instruct 是存輸入的指令的,score是暫存輸入的譜名的 int oldID, newID; /兩個存編號的 int count; /計數的 printf(歡迎來到管樂藏譜管理系統n); /*是否成功登入*/ if (Login() = 0) getch(); return 0; /*讓所有 Item 指向 NULL*/ for(count = 0; count = 3) printf(忘記密碼摟仔細想想吧!再見。n); return 0; printf(請輸入密碼:); scanf( %s, pass); test+;
6、 while(strcmp(pass, PASSWORD) != 0); return 1;2.2-int Load(void)l 說明:讀取檔案l 輸入參數:無l 傳回值:無l 流程圖: l 程式碼:int Load(void) int test, count; char YorN, AtoZ; Score Read; if (fh = fopen(DATAFILE, rb) = NULL) printf(檔案無法開啟,可能是您沒有權限或是檔案不存在。n); do printf(是否新增檔案(Y or N)?); scanf( %c, &YorN); if (toupper(YorN) =
7、Y) fh = fopen(DATAFILE, wb); fclose(fh); else if (toupper(YorN) = N) printf(感謝您的使用,再見。n); return 0; while(toupper(YorN) != Y); else test = 0; /*資料讀入*/ for (count = 0; count MAX_SIZE & !feof(fh); count+) fseek(fh, count * sizeof(Score), SEEK_SET); fread(&Read, sizeof(Score), 1, fh); if (Read.record !
8、= 0) test+; Scorescount = Read; Scorescount.nextPtr = NULL; cleanspace(Scorescount.scoreName); cleanspace(Scorescount.authorName); AtoZ = prefix(Scorescount.scoreName0); if (AtoZ - A) = 0) Insert(AtoZ - A, count + 1); /*顯示讀入成功*/ printf(初始化 %s 中, DATAFILE); for (count = 0; count 3; count+) printf(.);
9、 sleep(500); printf(完成!n); if (test = 0) printf(檔案是空的n); fclose(fh); return 1;2.3-int Add(int id)l 說明:新增檔案l 輸入參數:要增加的檔案編號l 傳回值:回傳1,新增成功l 流程圖:l 程式碼:int Add(int id) int count; char score20; printf(n新增編號 #%d 中.n, id); printf(樂譜名稱(中文請加註#):); fflush(stdin); fgets(score, 20, stdin); cleanenter(score); cle
10、anspace(score); if (cmp(score, ) = 0) printf(錯誤:樂譜名稱不能為空白。n); return 0; for (count = 0; count 7 | Scoresid - 1.level tm_year) + 1900; Scoresid - 1.date1 = (curtime-tm_mon) + 1; Scoresid - 1.date2 = (curtime-tm_mday); printf(新增日期:%04d/%02d/%02d.n, Scoresid - 1.date0, Scoresid - 1.date1, Scoresid - 1.
11、date2); Scoresid - 1.nextPtr = NULL; printf(編號 #%d %s 已新增。n, id, Scoresid - 1.scoreName); return 1;2.4-int Delete(int id)l 說明:刪除檔案l 輸入參數:要刪除的檔案編號l 傳回值:回傳1,刪除成功l 流程圖:l 程式碼:int Delete(int id) Score temp = Empty; temp.nextPtr = Scoresid - 1.nextPtr; printf(編號 #%d %s 已刪除。n, id, Scoresid - 1.scoreName);
12、Scoresid - 1 = temp; return 1;2.5-int Update(int id)l 說明:更改資料l 輸入參數:要刪除的檔案編號l 傳回值:回傳1,更改成功l 流程圖: l 程式碼;int Update(int id) int count; char score20; char author20; char types10; char level5; int level1; printf(n更新編號 #%d 中.n, id); printf(樂譜名稱(%s): , Scoresid - 1.scoreName); fflush(stdin); fgets(score,
13、20, stdin); cleanspace(score); if (strcmp(score, n) != 0) cleanenter(score); for (count = 0; count 7 | level1 tm_year) + 1900; Scoresid - 1.date1 = (curtime-tm_mon) + 1; Scoresid - 1.date2 = (curtime-tm_mday); printf(更新日期:%04d/%02d/%02d.n, Scoresid - 1.date0, Scoresid - 1.date1, Scoresid - 1.date2);
14、 printf(編號 #%d 已更新。n, id); return 1;2.6- int Move(int oldid, int newid)l 說明:移動檔案l 輸入參數:要移動的檔案編號及新位置l 傳回值:回傳1,移動成功l 流程圖:l 程式碼:int Move(int oldid, int newid) Scoresnewid - 1 = Scoresoldid - 1; Scoresnewid - 1.record = newid; Scoresoldid - 1 = Empty; time(&t); curtime = localtime(&t); Scoresnewid - 1.d
15、ate0 = (curtime-tm_year) + 1900; Scoresnewid - 1.date1 = (curtime-tm_mon) + 1; Scoresnewid - 1.date2 = (curtime-tm_mday); printf(移動日期:%04d/%02d/%02d.n, Scoresnewid - 1.date0, Scoresnewid - 1.date1, Scoresnewid - 1.date2); printf(編號 #%d 的資料已移至編號 #%d 的位置。n, oldid, newid); return 1;2.7- void Search(cha
16、r score)l 說明:尋找有相同字串的檔案l 輸入參數:欲尋找的字元l 傳回值:無l 流程圖:l 程式碼:void Search(char score) int count, count1, check = 0; char *ptr; /指向一個 char 的指標 char date12; /*找每一筆資料*/ for (count = 0; count MAX_SIZE; count+) /*沒有資料就跳過*/ if (Scorescount.record != 0) ptr = Scorescount.scoreName; for (count1 = 0; count1 (20 - s
17、trlen(score) + 1) & ptr0 != 0; count1+, ptr+) if (ptr0 = score0) if (strncmp(ptr, score, strlen(score) = 0) if (check = 0) printf(n樂譜資料中含有字串 %s 的為:n); printf(%-5s%-20s%-20s%-10s%-8s%-12sn, 編號, 樂譜名稱, 作曲家, 類型, 等級, 建立日期); sprintf(date, %04d/%02d/%02d0, Scorescount.date0, Scorescount.date1, Scorescount.
18、date2); printf(%-5d%-20s%-20s%-10s%-8d%-12sn, Scorescount.record, Scorescount.scoreName, Scorescount.authorName, Scorescount.type, Scorescount.level, date); check+; break; if (check = 0) printf(沒有含有字串 %s 的資料。n, score); else printf(共有 %d 筆資料。n, check); 2.8- void Sort(char lead, Score *currentPtr)l 說明:列出字首相同的資料l 輸入參數:要尋找的字首l 傳回值:無l 流程圖:l 程式碼:void Sort(char lead, Scor
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年荆门职业学院单招综合素质笔试备考题库含详细答案解析
- 2026年江西吉安市吉水县吉庆年华养老服务中心向社会招聘1名护士笔试模拟试题及答案解析
- 首汽约车培训
- 2026新疆昆仑国有资产经营有限公司招聘2人笔试模拟试题及答案解析
- 2026年常州信息职业技术学院单招综合素质笔试参考题库含详细答案解析
- 2026安徽芜湖市皖南医学院第一附属医院(弋矶山医院)博士及高层次人才招聘22人笔试参考题库及答案解析
- 2026河北省第七人民医院招聘工作人员6人笔试备考试题及答案解析
- 2026广东广州花都区新华街第四小学招聘文员1人笔试模拟试题及答案解析
- 2026广东清远市英德市教育服务中心招聘见习人员2人笔试模拟试题及答案解析
- 2026济钢集团有限公司校园招聘(13人)笔试模拟试题及答案解析
- 2026湖南衡阳日报社招聘事业单位人员16人备考题库参考答案详解
- GB 12801-2025生产过程安全基本要求
- 食堂管理内控制度
- 2025至2030中国数据分析超级计算机(DAS)行业项目调研及市场前景预测评估报告
- 口腔种植知识培训内容课件
- 展会搭建方案(3篇)
- 危重患者护理记录书写
- 小学语文数字化教学论文
- 尼康-D300S-相机说明书
- 锅炉专业英文术语
- 标准规范文件:GB-T3956-2008电缆的导体
评论
0/150
提交评论