C語言課程設(shè)計雜志閱讀管理軟件_第1頁
C語言課程設(shè)計雜志閱讀管理軟件_第2頁
C語言課程設(shè)計雜志閱讀管理軟件_第3頁
C語言課程設(shè)計雜志閱讀管理軟件_第4頁
C語言課程設(shè)計雜志閱讀管理軟件_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、c語言課程設(shè)計題目名稱: 姓 名: 學(xué) 號:班級序號:指導(dǎo)老師: 目錄前言 * 2設(shè)計思路及要求 * 31.程序設(shè)計思路 * 32.程序設(shè)計要求 * 3程序總體設(shè)計流程圖 * 5功能模塊的調(diào)試和測試 * 51.增加訂戶模塊 * 62.刪除過期訂戶 * 73.輸出所有信息 * 84.統(tǒng)計本月訂戶 * 95.查詢用戶 * 10程序設(shè)計的原代碼 * 11結(jié)束語 * 18前言c語言是一種計算機(jī)程序設(shè)計語言。它既有高級語言的特點(diǎn),又具有匯編語言的特點(diǎn)。它可以作為系統(tǒng)設(shè)計語言,編寫工作系統(tǒng)應(yīng)用程序,也可以作為應(yīng)用程序設(shè)計語言,編寫不依賴計算機(jī)硬件的應(yīng)用程序。c語言是一種結(jié)構(gòu)化語言。它層次清晰,便于按模塊化

2、方式組織程序,易于調(diào)試和維護(hù)。c語言的表現(xiàn)能力和處理能力極強(qiáng)。它不僅具有豐富的運(yùn)算符和數(shù)據(jù)類型,便于實(shí)現(xiàn)各類復(fù)雜的數(shù)據(jù)結(jié)構(gòu)。它還可以直接訪問內(nèi)存的物理地址,進(jìn)行位(bit)一級的操作。因此,它的應(yīng)用范圍廣泛。c語言在很多方面都可以用,不僅僅是在軟件開發(fā)上,各類科研都是需要用到c語言的。具體應(yīng)用比如我是學(xué)硬件的,單片機(jī)以及嵌入式系統(tǒng)都可以用c來開發(fā)。c 語言發(fā)展如此迅速, 而且成為最受歡迎的語言之一,主要因?yàn)樗哂袕?qiáng)大的功能。許多著名的系統(tǒng)軟件, 如dbase plus、dbase 都是由c 語言編寫的。用c語言加上一些匯編語言子程序, 就更能顯示c 語言的優(yōu)勢了, 像pc- dos 、word

3、star等就是用這種方法編寫的。在信息化迅速更新的今天,計算機(jī)已經(jīng)普及,而c語言為計算機(jī)的更新?lián)Q代提供了很好的基礎(chǔ)平臺,作為當(dāng)代的大學(xué)生學(xué)好c語言是很重要的。為此學(xué)校為我們提供了提高c語言專業(yè)知識的載體,為我們開設(shè)了c語言上機(jī)實(shí)習(xí)課程。設(shè)計思路及要求程序設(shè)計思路c語言程序設(shè)計主要是利用c語言的設(shè)計操作能力設(shè)計出一個雜志訂閱管理系統(tǒng),一個完整的雜志訂閱管理軟件至少應(yīng)該具有:(1)能夠提供文件的儲存、輸入、輸出、刪除等操作;(2)能夠提供文件的添加操作,增加新用戶等操作;(3)能夠提供文件的查詢,查找等操作;(4)能夠通過文件的刪除操作紀(jì)實(shí)刪除已到期的訂戶記錄;(5)能夠提供統(tǒng)計和顯示操作統(tǒng)計本期

4、雜志本期用戶數(shù)并打印運(yùn)算結(jié)果;(6)另外文件還要具備提供鍵盤式選擇菜單以實(shí)現(xiàn)功能選擇.程序設(shè)計要求c語言程序的設(shè)計需要明確課程設(shè)計的目的,能根據(jù)課程設(shè)計的要求,查閱相關(guān)文獻(xiàn),為完成設(shè)計準(zhǔn)備必要的知識,提高學(xué)生用高級語言進(jìn)行程序設(shè)計的能力,重點(diǎn)提高用c語言進(jìn)行文件操作和繪圖應(yīng)用的編程技術(shù)水平,并能夠初步了解軟件開發(fā)的一般方法和步驟,提高撰寫技術(shù)文檔的能力。而對于本次程序設(shè)計的要求則是:使用計算機(jī)對一種雜志的訂閱進(jìn)行管理,該雜志擁有的最多用戶不能超過10人,每個訂戶的信息包括:姓名,性別,地址,電話號碼,雜志單價,訂閱數(shù),訂閱的期限(至*年*月)。要求用菜單選擇并完成下述功能:(1) 增加新用戶,

5、即將訂戶的全部信息輸入的文件中;(2) 根據(jù)當(dāng)天的日期對訂戶文件進(jìn)行查詢,刪除已到期的訂戶記錄:(3) 統(tǒng)計本期雜志訂戶數(shù)并打印運(yùn)算結(jié)果:本期訂戶信息表訂戶名 訂閱數(shù) 單價 金額李平 2 5.5 11.0黃海 1 5.5 5.5合計 3 1.0 16.5程序總體設(shè)計流程圖功能模塊的調(diào)試和測試1.增加訂戶模塊 2.刪除過期訂戶在上圖中我假設(shè)當(dāng)前時間為20080808對文件中訂戶信息進(jìn)行更新。下面來看看保存有訂戶信息的文本文件中的數(shù)據(jù)情況。在上圖中我們可以看出所有的到期時間在20080808之前的訂戶的信息都被一段特殊的信息所代替。3.輸出所有信息在上圖中我輸出了在msg.txt中的所有訂戶的信息

6、。4.統(tǒng)計本月訂戶上圖中假設(shè)這個月是20080808。注意這個功能與刪除過期訂戶的差異,統(tǒng)計功能只是輸出文件中沒有過期的訂戶,而沒有在文件中將過期的訂戶刪除,而刪除過期訂戶在文件中將過期的訂戶刪除。5.查詢用戶以上是查詢姓名是xiao的訂戶的信息。 程序設(shè)計的原代碼#include stdio.h#include string.h#include stdlib.htypedef struct msgchar name20;char sex10;char dialnumber11; int count; float price; float money; char date20;char rea

7、deraddr50;msgnode;void start()printf(*n);printf(* writen by david x.h. of cug *n);printf(* *n);printf(* *n);printf(* david x.h. all rights reserved *n);printf(*n);void textout()printf(ttwanna check message,press-0.nn); printf(ttwanna add a new reader,press-1.nn);printf(ttwanna update the message tab

8、le,press-2.nn);printf(ttwanna output all the message ,press-3.nn);printf(ttwanna display readers this month. ,press-4.nn);printf(ttwanna exit,press-5.nn);int checkdatemon(char * date) char chdate3; chdate0=date5; chdate1=date6; chdate2=0; return atoi(chdate);int checkdateday(char * date)char chdate3

9、;chdate0=date8;chdate1=date9; chdate2=0; return atoi(chdate);int addreader()file *fp; msgnode ad; if(fp=fopen(msg.txt,at)=null)printf(cannot open the file or cannot find the file.please check out .n); getch(); return 0;printf(input start. _ n); printf(please input the name: _ n); scanf(%s,);p

10、rintf(please input the sexmale/female: _ n); scanf(%s,ad.sex);printf(please input the dialnumber: _ n); scanf(%s,ad.dialnumber); printf(please input the count: _ n); scanf(%d,&ad.count); printf(please input the price: _ n); scanf(%f,&ad.price); printf(please input the date: _ n); scanf(%s,ad.date);

11、while(ad.date4!=.| ad.date7!=.| strlen(ad.date)!=10 |checkdatemon(ad.date)=13|checkdateday(ad.date)=32)printf(the format is not right or the date is not existed.n ); printf(you should input the date like this yyyy.mm.ddn);printf(please input the date again: _ n); scanf(%s,ad.date);printf(please inpu

12、t the address of reader: _ n); scanf(%s,ad.readeraddr); fprintf(fp,%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,,ad.sex,ad.dialnumber,ad.count,ad.price,ad.count*ad.price,ad.date,ad.readeraddr); fclose(fp); return 1;int updatemsg(char *currdate)msgnode currnode,movenode ; int i=0,j=0; file *fp;

13、if(fp=fopen(msg.txt,rt+)=null)printf(%s n,cannot open the file or cannot find the file.please check out .); return 0;i=ftell(fp); fscanf(fp,%s%s%s%d%f%f%s%s ,,currnode.sex,currnode.dialnumber,&currnode.count,&currnode.price,&currnode.money,currnode.date,currnode.readeraddr); j=ftell(fp)

14、;j=j-i;rewind(fp);while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s ,,currnode.sex,currnode.dialnumber ,&currnode.count,&currnode.price,&currnode.money,currnode.date,currnode.readeraddr);if(feof(fp)break;if(strcmp(currdate,currnode.date)0) fseek(fp,-j,1); fprintf(fp,%15s %8s %13s %7d %7.2f %10.

15、2f %13s %-50s ,null,null,null,0,0.0,0.0,9999.99.99,null); fseek(fp,2l,1); return 1;int outputall()file *fp; msgnode oa; int allcount=0; float allmoney=0; if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cannot find the file.please check out .n); getch();return 0; printf(%15s %8s %13s %7s

16、%7s %10s %13s %-50sn,readername ,readsex ,number ,count ,price ,moneysum ,date ,readeraddress); while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s,,oa.sex,oa.dialnumber,&oa.count,&oa.price,&oa.money,oa.date,oa.readeraddr);if(feof(fp)break; allcount+=oa.count; allmoney+=oa.money;if(strcmp(oa.sex,null)

17、printf(%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,,oa.sex,oa.dialnumber,oa.count,oa.price,oa.money, oa.date,oa.readeraddr); printf(%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,heji,-,-,allcount,-,allmoney,2007.09.04,-);return 1;int checkreader(char *name)file *fp; int i,j; char ch; msgnode cr;

18、if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cannot find the file.please check out .);getch(); return 0;i=ftell(fp); fscanf(fp,%s%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr); j=ftell(fp); rewind(fp); j=j-i;while(!feof(fp)fscanf(fp,%s

19、%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr); i=ftell(fp);if(!strcmp(,name)printf(the reader you are checking is existed in the list.n);fseek(fp,-j,1); fscanf(fp,%s%s%s%d%f%f%s%s ,,cr.sex,cr.dialnumber,&cr.count ,&cr.price,&cr.money,c

20、r.date,cr.readeraddr);if(feof(fp)break; printf(%15s %8s %13s %7d %7f %10f %13s %-50sn ,,cr.sex,cr.dialnumber,cr.count ,cr.price,cr.money,cr.date,cr.readeraddr);return 1;int displayreader(char *date)file *fp; int i,j; msgnode cr; if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cann

21、ot find the file.please check out .);getch(); return 0;while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr);if(feof(fp)break;if(!strcmp(9999.99.99,cr.date)continue;if(strcmp(date,cr.date)0 ) printf(%15s %8s %13s %7d %7f %10f %13s

22、 %-50sn ,,cr.sex,cr.dialnumber,cr.count ,cr.price,cr.money,cr.date,cr.readeraddr);return 1;main() char str30;int ch;start();textout();scanf(%d,&ch);while(ch!=5)if(ch=0)printf(please input the name you wanna index: _n);scanf(%s,str);if(checkreader(str)printf(you have successfully index the reader!n); textout();scanf(%d,&ch);continue ; if(ch=1)if(addreader()printf(you have successfully add a reader!n);textout();scanf(%d,&ch);continue ;if(ch=2)printf(please input the current date: _n);scanf(%s,str); if(updatemsg(str)printf

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論