C語言實現超市計價收款系統_第1頁
C語言實現超市計價收款系統_第2頁
C語言實現超市計價收款系統_第3頁
C語言實現超市計價收款系統_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

第C語言實現超市計價收款系統本文實例為大家分享了C語言實現超市計價收款系統的具體代碼,供大家參考,具體內容如下

學習一個月的C語言,寫了一個簡易的超市計價收款系統

源碼如下

#includestdio.h

#includestdlib.h

#includestring.h

#defineM10

typedefstruct

//定義商品的結構體

charname[10];

intnum;

float

price;

intID;

}Store;

Storestore[M];

voidshuru()

//定義輸入商品的函數

inti;

intisgo;

intn;

for(i=0;ii++)

{

store[i].ID=i+1;//自定義商品的ID

printf("輸入商品的名字\n");

scanf("%s",store[i].name);

printf("輸入商品的價格\n");

scanf("%f",store[i].price);

printf("還需要輸入商品嗎?\n");

printf("1.YES,2.NO\n");

scanf("%d",isgo);

if(isgo!=2)//判斷是否繼續輸入商品

{

}else//不輸入商品直接跳出,展示所有商品的信息

{

for(n=0;nn++)

{

printf("商品ID\t商品名字\t商品價格\n");

printf("%d\t,%s\t,%f\n",store[n].ID,store[n].name,store[n].price);

}

i=10;

}

}

voidshopp()

//購物函數

intisgo=1;

inti;

intn;

intnumber;

intshoppid;

floatpricenum;

floatpricesum=0.0;

floatpriceguke;

printf("庫存的商品如下\n");

for(n=0;nn++)

{

printf("商品ID\t商品名字\t商品價格\n");

printf("%d\t,%s\t,%f\n",store[n].ID,store[n].name,store[n].price);

if(store[n].price==0)//這里是為了不把沒定義的商品不顯示出來

{

n=M;

}

}

while(isgo)//購物

{

printf("按下你需要的商品ID和數量\n");

scanf("%d,%d",shoppid,number);

pricenum=(store[shoppid-1].price)*number;

pricesum=pricesum+pricenum;

printf("你購買的商品%s是%d個,價格是%f,總金額是%f\n",store[shoppid-1].name,number,pricenum,pricesum);

printf("是否繼續購物\n");

printf("0.退出,1.繼續\n");

scanf("%d",isgo);

}

printf("輸入顧客支付的金錢\n");//結算

scanf("%f",priceguke);

if(priceguke=pricesum)

{

printf("收到顧客%f元,找回顧客%f元\n",priceguke

溫馨提示

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

評論

0/150

提交評論