freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

個人消費管理系統(tǒng)c語言課程設(shè)計畢業(yè)設(shè)計word格式-文庫吧

2025-10-21 07:21 本頁面


【正文】 , nCurrent是已存消費條目的個數(shù),index為索引號,利用循環(huán)遍歷所有的索引號,如果遇到的索引號與要刪除的索引號相同,則實現(xiàn)調(diào)用刪除函數(shù) 8 DeleteRecord(ConsumeRecord* record,intamp。 nCurrent,int index)功能,即: { for (int i = 0。inCurrent。i++) { if (recordindex==index) { for (int j = i。jnCurrent。j++) { record[j]=record[j+1]。 } nCurrent。 } } } 插入數(shù)據(jù)時首先要判斷條目是否已滿,若已滿則輸出 printf(the record is full!)。即已經(jīng)存滿不能再插入數(shù)據(jù),否則 將 pCurrent指向已存條目的下一個位置指針 即 pCurrent=amp。record[nCurrent]。循環(huán)直到 正確 輸入 若 輸入不正確,打印警告信息 即: if (pCurrentnum0) { printf(unreannd fomat!\n)。 9 } } 插入后 計算總金額 pCurrentsum=pCurrentprice*pCurrentnum。 pCurrent++。 nCurrent++。 } pCurrent=amp。record[nCurrent]。 如下: Record: 指向消費條目記錄數(shù)組, nCurrent: 已存條目數(shù), index: 需要查找的條目的索引號 利用 ConsumeRecord* FindRecord(ConsumeRecord* record,intamp。 nCurrent,int index) 遍歷所有已存的消費條目,直到查找完或者找到如果消費條目的索引號為需要查找的索引號才,找到了,返回 ; 遍歷完了沒有找到,輸出 “not found!”即: { for (int i = 0。inCurrent。i++,record++) 10 { if (recordindex==index) { return record。 } } printf(not found!)。 return 0。 } 查找完后調(diào)用 ShowRecord輸出要顯示的條目 。 ShowRecord函數(shù)功能如下: void ShowRecord(ConsumeRecord* record) { printf(index:%d %d%d%d type:%d name:%s price:%f num:%d sum:%f\n,\ recordindex,record,record,record,recordtype,recordname,recordprice,recordnum,recordsum)。 } 然后調(diào)用顯示 ShowRecords查找到的從指針開始的總的條目,ShowRecords功能如下: void ShowRecords(ConsumeRecord* record,int number) { 11 for (int i=0。inumber。i++) { ShowRecord(record+i)。 } } 注: number:需要顯示的條目數(shù)。 Record:指向第一個要顯示的指針。 D. 排序模塊:按時間,類別,金額 具體來說是定義了一個函數(shù),實現(xiàn)三種方式的排序,其中運用了switch語句,根據(jù)不同的排序類型劃分了不同的 case,然后選擇出相應(yīng)的功能來實現(xiàn)要求,比較實用而且簡潔。函數(shù)內(nèi)部是采用冒泡法排序,首先判斷選擇的類型然后進入相應(yīng)的功能區(qū)。定義函數(shù) void SortRecord(ConsumeRecord* record,int nCurrent,char type) 其中 record: 排序數(shù)組頭指針, nCurrent: 數(shù)組的個數(shù), type: 排序類型 void SortRecord(ConsumeRecord* record,int nCurrent,char type) { int i,j。 switch(type) { case 39。t39。: //按時間排序 12 for(i=0。inCurrent1。i++) { for(j=0。jnCurrent1i。j++) { //比較兩個條目的年份,前一個年份大則交換 if(record[j].record[j+1].) { swap(amp。record[j],amp。record[j+1])。 } else if //年份相同,比較月份 (record[j].==record[j+1].amp。amp。record[j].record[j+1].) { swap(amp。record[j],amp。record[j+1])。 } else if //年份月份相同,比較日期 (record[j].==record[j+1].amp。amp。record[j].==record[j+1].amp。amp。record[j].record[j+1].) { swap(amp。record[j],amp。record[j+1])。 13 } } } break。 //按類型排序 case 39。l39。: for(i=0。inCurrent1。i++) { for(j=0。jnCurrent1i。j++) { //比較類型,前面的條目大就交換 if(record[j].typerecord[j+1].type) { swap(amp。record[j],amp。record[j+1])。 } } } break。 //按價格排序 case 39。p39。: for(i=0。inCurrent1。i++) 14 { for(j=0。jnCurrent1i。j++) { //遍歷價格,前面的大就交換 if(record[j].pricerecord[j+1].price) { swap(amp。record[j],amp。record[j+1])。 } } } break。 } } 如下: 15 E.統(tǒng)計模塊 為了便于統(tǒng)計,現(xiàn)將數(shù)據(jù)進行排序,根據(jù)不同的統(tǒng)計方式進行不同的排序 ,如為了計算每年的消費總額,需要將數(shù)據(jù)按時間排序,然后進行統(tǒng)計,按類型排序就利于統(tǒng)計每個項目的消費情況。在程序中就要在統(tǒng)計之前根據(jù) 需要調(diào)用相應(yīng)的函數(shù)實現(xiàn)排序功能。具體如下所示: void Statistic(ConsumeRecord* record,int nCurrent) { //如果已存條目小于等于零,退出 if (nCurrent=0) { return。 } 16 //將條目按時間排序 SortRecord(record,nCurrent,39。t39。)。 double sumYear = recordsum。//按年統(tǒng)計的總金額,將第一條記錄的金額付給他 double sumMonth = recordsum。//按月統(tǒng)計的總金額,將第一條記錄的金額付給他 double sumType = recordsum。//按類型統(tǒng)計的總金額,將第一條記錄的金額付給他 //如果只有一條記錄直接輸出 if (nCurrent == 1) { //輸出按年統(tǒng)計的總金額 printf(year:%d sum:%f\n,record[0].,sumYear)。 //輸出按月統(tǒng)計的總金額 printf(year:%dmonth%d: sum:%f\n,record[0].,record[0].,sumMonth)。 //輸出按類型統(tǒng)計的總金額 printf(type:%d sum:%f\n,record[0].type,sumType)。 return。 } //如果有多條記錄,則遍歷所有記錄并分別打印 for (int i=0。inCurrent。i++) 17 { //如果當(dāng)前記錄與下一條記錄年份相同,則將其歸于一年,并累加改年的總金額 if (record[i].==record[i+1].) { sumYear+=record[i+1].sum。 } else { //年份變了,打印統(tǒng)計年份的總金額 printf(year:%d sum:%f\n,record[i].,sumYear)。 //將年份金額賦值為下一年份,開始記錄下一年分 sumYear=record[i+1].sum。 } //如果當(dāng)前記錄與下一條記錄年份月份相同,則將其歸于一個月,并累加該月的總金 額 if (record
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1