本帖最後由 黃崇維 於 2013-6-29 16:24 編輯
- #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<<"[使用說明]"<<endl;
- cout<<"依序輸入想購買的商品與數量,如電腦兩台請輸入'7 2'"<<endl;
- cout<<"選購完畢時輸入'8 8'進入結帳頁"<<endl<<endl;
- start:
- cout<<"在此輸入: ";
- cin>>p>>q;
- if(p>=1 && p<=7 && q>0)
- {
- sum=sum+price[p-1]*q;
- goto start;
- }else if(p==8 && q==8)
- {
- goto checkout;
- }else
- {
- cout<<"輸入錯誤!!"<<endl;
- goto start;
- }
- checkout:
- cout<<endl<<"總共"<<sum<<"元!"<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |