- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string name[]={"憤怒鳥 ","狼牙棒 ","冷氣","殺手/一個人","不求人抓抓背快樂抓抓小手","劉博士用過的毛巾","踩劉博士走過的路"};
- int price[]={};
- int qty[]={0,0,0,0,0,0,0};
- int p, q, money, pay, sum=0, a;
- cout<<"劉博士之甚麼都賣店"<<endl<<endl;
- cout<<"[只有聰明人才看的到的價目表]"<<endl;
- cout<<"(1)憤怒鳥\t\t300元/隻"<<endl;
- cout<<"(2)狼牙棒\t\t799元"<<endl;
- cout<<"(3)冷氣\t\t80000元"<<endl;
- cout<<"(4)殺手/一個人\t\t200元"<<endl;
- cout<<"(5)不求人抓抓背快樂抓抓小手\t1399元"<<endl;
- cout<<"(6)劉博士用過的毛巾/條\t100000元"<<endl;
- cout<<"(7)踩劉博士走過的路/一步\t3000元"<<endl;
- cout<<"(8)結帳"<<endl<<endl;
- start:
- cout<<"請輸入商品代碼: ";
- cin>>p;
- if(p==8)
- {
- goto checkout;
- }else if(p>=1 && p<=7)
- {
- cout<<"請輸入數量:";
- cin>>q;
- if(q>0)
- {
- sum=sum+price[p-1]*q;
- qty[p-1]=q;
- goto start;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }
- checkout:
- cout<<endl<<"[購物清單]"<<endl;
- cout<<"-------------"<<endl;
- for(int i=0; i<=6; i++)
- {
- if(qty[i]!=0)
- cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
- }
- cout<<"-------------"<<endl;
- cout<<"\t\t總共"<<sum<<"元!"<<endl;
- cout<<"1-正確無誤 2-重新選購"<<endl;
- cout<<"請輸入你要的"<<endl;
- cin>>a;
- if(a==1)
- cout<<"Please摳摳拿來!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |