本帖最後由 黃崇維 於 2013-7-6 15:18 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int price[]={10000,12000,12300,12340,12345,123456,1234567};
- int p, q, money, pay, sum=0;
- cout<<"崇維智能電腦房屋店"<<endl<<endl;
- cout<<"[電腦價目表]"<<endl;
- cout<<"(1)一星級電腦\t10000元"<<endl;
- cout<<"(2)二星級電腦\t12000元"<<endl;
- cout<<"(3)三星級電腦\t12300元"<<endl;
- cout<<"(4)四星級電腦\t12340元"<<endl;
- cout<<"(5)五星級電腦\t12345元"<<endl;
- cout<<"(6)六星級電腦\t123456元"<<endl;
- cout<<"(7)七星級電腦\t1234567元"<<endl;
- cout<<"(8)結帳"<<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;
- goto start;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }
- }
- checkout:
- cout<<endl<<"總共"<<sum<<"元!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |