模仿全球通計費系統(tǒng)的源代碼.doc_第1頁
模仿全球通計費系統(tǒng)的源代碼.doc_第2頁
模仿全球通計費系統(tǒng)的源代碼.doc_第3頁
模仿全球通計費系統(tǒng)的源代碼.doc_第4頁
模仿全球通計費系統(tǒng)的源代碼.doc_第5頁
已閱讀5頁,還剩11頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

#include#include#include#includetypedef structchar TelNum112; /用戶的號碼char TelNum212; /用戶所撥打的號碼char Time111; /撥打電話的起始時間的年、月、日(如2012/12/12)char Time29; /撥打電話的起始時間int Duration; /通話所用的時間(秒)double cost; /本次通話的話費TEL;#define adress1 .txt#define adress2 通話信息/double COST(int Duration); /計算呢本次通話所用的費用void Tel_inf(); /輸入并儲存通話信息void Detail_Bill(); /通話詳單查詢void Interface (); /主界面void Tel_inf_gui(); /輸入通話信息的界面void Inquires(); /查詢界面void Gotoxy(int x, int y); /光標(biāo)函數(shù)void Bill(); /賬單查詢void Gotoxy(int x, int y) /定位到第y行的第x列 int xx=0x0b; HANDLE hOutput; COORD loc; loc.X = x; loc.Y=y; hOutput = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOutput, loc); return; /輸入通話記錄的界面/按“1”開始輸入通話信息/按“2”返回主界面void Tel_inf_gui()int m;system(cls);system(color 34);Gotoxy(0,7);printf(tt/*/n);printf(ttt 請選擇要進行的操作: n);printf(nttt 確認 t 返回n);printf(tt/*/n);m=getch();switch(m)case 1:Tel_inf(); /輸入用戶的通話記錄break;case 2:Interface (); /返回主界面break;default:Tel_inf_gui(); break;/輸入并儲存通話信息void Tel_inf()TEL Tel; char Filename30;FILE *fp=NULL;system(cls);system(color 34);printf(請依次輸入用戶的手機號碼,用戶所撥打的手機號碼,通話的起始時間(如2011/12/12 03:12:34),通話的時長(以秒為單位)。);printf(以“#”為結(jié)束標(biāo)志n);while( ( scanf(%s,Tel.TelNum1) )!=EOF)if( strcmp(Tel.TelNum1,#)=0 )printf(按任意鍵返回n);getch();Interface ();break;/輸入用戶的手機號碼,用戶所撥打的手機號碼,通話的起始時間(如2011/12/12 03:12:34),通話的時長(以秒為單位) scanf( %s %s %s %d ,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration);strcpy(Filename,adress2);strcat(Filename,Tel.TelNum1);strcat(Filename,adress1);Tel.cost=COST(Tel.Duration);fp=fopen(Filename , a); /打開儲存用戶通話記錄的文件fprintf(fp,%s %s %s %d %fn,Tel.TelNum2,Tel.Time1,Tel.Time2,Tel.Duration,Tel.cost); /將用戶的通話信息寫入文件中fclose(fp); /計算本次通話所用的費用double COST(int Duration)double cost; /本次通話的費用int duraction1; if( Duration%60=0 )duraction1=(Duration/60);elseduraction1=(Duration/60)+1;cost=0.3*duraction1;return cost;/輸出所查月份的詳細賬單void Detail_Bill()TEL Tel;FILE *fp;char Filename30;char time110;char time210;char telnum12;system(cls);system(color 34); Gotoxy(0,10);printf(tt請輸入要查詢的號碼:);scanf(%s,telnum);strcpy(Filename,adress2);strcat(Filename,telnum);strcat(Filename,adress1);if(fp=fopen(Filename,r) /檢查所輸入的號碼是否有效,若有效則讀取信息,若無效則重新輸入printf(ntt請輸入要查詢的月份(如2011/12):); scanf(%s,time1);system(cls); system(color 34);/從文件中讀取用戶的通話信息,并輸出printf(對方號碼t 通話起始時間 通話時長(秒) 通話費用n);while( fscanf(fp,%s %s %s %d %lf,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration,&Tel.cost)!=EOF )strncpy(time2,Tel.Time1,7);time27=0;if(strcmp(time1,time2)=0)printf(%-15s %s %s %7d %15.2fn,Tel.TelNum2,Tel.Time1,Tel.Time2,Tel.Duration,Tel.cost);fclose(fp);elsesystem(cls); system(color 34);Gotoxy(0,10);printf(tt您所輸入的號碼不存在,按任意鍵重新輸入n);getch();Detail_Bill();/按任意鍵返回主界面printf(tt按任意鍵返回主界面);getch();Interface();/計算并輸出所查月份的賬單void Bill()TEL Tel;FILE *fp;char Filename30;char time110;char time210;char telnum12;double total=0;system(cls);system(color 34); Gotoxy(0,10);printf(tt請輸入要查詢的號碼:);scanf(%s,telnum);strcpy(Filename,adress2);strcat(Filename,telnum);strcat(Filename,adress1);if(fp=fopen(Filename,r)printf(ntt請輸入要查詢的月份(如2011/12):);/輸入要查詢的月份(如2011/12) scanf(%s,time1);system(cls); system(color 34);Gotoxy(0,10);/從文件中讀取用戶的通話信息while( fscanf(fp,%s %s %s %d %lf,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration,&Tel.cost)!=EOF )strncpy(time2,Tel.Time1,7);time27=0;if(strcmp(time1,time2)=0)total+=Tel.cost; /計算所查月份的通話賬單/輸出所查月份的通話賬單printf(tt%s的話費為:%.2f元n,time1,total);fclose(fp);elsesystem(cls); system(color 34); Gotoxy(0,10);printf(tt您所輸入的號碼無效,按任意鍵重新輸入n);getch();Bill(); /輸入的號碼無效時重新輸入要查詢的號碼printf(tt按任意鍵返回主界面);getch();Interface(); /返回主界面/主界面/按“1”進入輸入用戶通話信息的界面/按“2”計入查詢界面/按“0”退出系統(tǒng)void Interface ()int m;system(cls); system(color 34);Gotoxy(0,6);printf(tt/*/n);printf(ttt 請選擇要進行的操作: n);printf(nttt 輸入用戶的通話信息 n);printf(ttt 查詢 n);printf(ttt 退出系統(tǒng) n);printf(tt/*/n);m=getch();switch(m)case 0:break; /退出系統(tǒng)case 1:Tel_inf_gui(); /進入輸入用戶通話信息的界面break;case 2:Inquires(); /進入查詢界面break;default:Interface ();/查詢界面/按“1”進行賬單查詢/按“2”進行詳單查詢/按“0”返回主界面void Inquires()int m;system(cls); system(color 34);Gotoxy(0,6);printf(tt/*/n);printf(nttt 賬單查詢 n);printf(ttt 詳單查詢 n);printf(ttt 返回主界面 n);printf(tt/*/n);m=getch();switch(m)case 0:Interface (); /返回主界面break;case 1:Bill(); /賬單查詢break;case 2:Detail_Bill(); /詳單查詢break;default:Inquires(); void main()Interface ();#include#include#include#includetypedef structchar TelNum112; /用戶的號碼char TelNum212; /用戶所撥打的號碼char Time111; /撥打電話的起始時間的年、月、日(如2012/12/12)char Time29; /撥打電話的起始時間int Duration; /通話所用的時間(秒)double cost; /本次通話的話費TEL;#define adress1 .txt#define adress2 通話信息/double COST(int Duration); /計算呢本次通話所用的費用void Tel_inf(); /輸入并儲存通話信息void Detail_Bill(); /通話詳單查詢void Interface (); /主界面void Tel_inf_gui(); /輸入通話信息的界面void Inquires(); /查詢界面void Gotoxy(int x, int y); /光標(biāo)函數(shù)void Bill(); /賬單查詢void Gotoxy(int x, int y) /定位到第y行的第x列 int xx=0x0b; HANDLE hOutput; COORD loc; loc.X = x; loc.Y=y; hOutput = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(hOutput, loc); return; /輸入通話記錄的界面/按“1”開始輸入通話信息/按“2”返回主界面void Tel_inf_gui()int m;system(cls);system(color 34);Gotoxy(0,7);printf(tt/*/n);printf(ttt 請選擇要進行的操作: n);printf(nttt 確認 t 返回n);printf(tt/*/n);m=getch();switch(m)case 1:Tel_inf(); /輸入用戶的通話記錄break;case 2:Interface (); /返回主界面break;default:Tel_inf_gui(); break;/輸入并儲存通話信息void Tel_inf()TEL Tel; char Filename30;FILE *fp=NULL;system(cls);system(color 34);printf(請依次輸入用戶的手機號碼,用戶所撥打的手機號碼,通話的起始時間(如2011/12/12 03:12:34),通話的時長(以秒為單位)。);printf(以“#”為結(jié)束標(biāo)志n);while( ( scanf(%s,Tel.TelNum1) )!=EOF)if( strcmp(Tel.TelNum1,#)=0 )printf(按任意鍵返回n);getch();Interface ();break;/輸入用戶的手機號碼,用戶所撥打的手機號碼,通話的起始時間(如2011/12/12 03:12:34),通話的時長(以秒為單位) scanf( %s %s %s %d ,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration);strcpy(Filename,adress2);strcat(Filename,Tel.TelNum1);strcat(Filename,adress1);Tel.cost=COST(Tel.Duration);fp=fopen(Filename , a); /打開儲存用戶通話記錄的文件fprintf(fp,%s %s %s %d %fn,Tel.TelNum2,Tel.Time1,Tel.Time2,Tel.Duration,Tel.cost); /將用戶的通話信息寫入文件中fclose(fp); /計算本次通話所用的費用double COST(int Duration)double cost; /本次通話的費用int duraction1; if( Duration%60=0 )duraction1=(Duration/60);elseduraction1=(Duration/60)+1;cost=0.3*duraction1;return cost;/輸出所查月份的詳細賬單void Detail_Bill()TEL Tel;FILE *fp;char Filename30;char time110;char time210;char telnum12;system(cls);system(color 34); Gotoxy(0,10);printf(tt請輸入要查詢的號碼:);scanf(%s,telnum);strcpy(Filename,adress2);strcat(Filename,telnum);strcat(Filename,adress1);if(fp=fopen(Filename,r) /檢查所輸入的號碼是否有效,若有效則讀取信息,若無效則重新輸入printf(ntt請輸入要查詢的月份(如2011/12):); scanf(%s,time1);system(cls); system(color 34);/從文件中讀取用戶的通話信息,并輸出printf(對方號碼t 通話起始時間 通話時長(秒) 通話費用n);while( fscanf(fp,%s %s %s %d %lf,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration,&Tel.cost)!=EOF )strncpy(time2,Tel.Time1,7);time27=0;if(strcmp(time1,time2)=0)printf(%-15s %s %s %7d %15.2fn,Tel.TelNum2,Tel.Time1,Tel.Time2,Tel.Duration,Tel.cost);fclose(fp);elsesystem(cls); system(color 34);Gotoxy(0,10);printf(tt您所輸入的號碼不存在,按任意鍵重新輸入n);getch();Detail_Bill();/按任意鍵返回主界面printf(tt按任意鍵返回主界面);getch();Interface();/計算并輸出所查月份的賬單void Bill()TEL Tel;FILE *fp;char Filename30;char time110;char time210;char telnum12;double total=0;system(cls);system(color 34); Gotoxy(0,10);printf(tt請輸入要查詢的號碼:);scanf(%s,telnum);strcpy(Filename,adress2);strcat(Filename,telnum);strcat(Filename,adress1);if(fp=fopen(Filename,r)printf(ntt請輸入要查詢的月份(如2011/12):);/輸入要查詢的月份(如2011/12) scanf(%s,time1);system(cls); system(color 34);Gotoxy(0,10);/從文件中讀取用戶的通話信息while( fscanf(fp,%s %s %s %d %lf,Tel.TelNum2,Tel.Time1,Tel.Time2,&Tel.Duration,&Tel.cost)!=EOF )strncpy(time2,Tel.Time1,7);time27=0;if(strcmp(time1,time2)=0)total+=Tel.cost; /計算所查月份的通話賬單/輸出所查月份的通話賬單printf(tt%s的話費為:%.2f元n,time1,total);fclose(fp);elsesystem(cls); system(

溫馨提示

  • 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論