- #include<cstdlib>
- #include<iostream>
- using namespace std;
- int main(){
- string m[8]={"兔子布偶","文具組合","高級餅乾","鍵盤滑鼠","遊戲點數","藍色外套","神秘獎品","結帳"};
- int n[8]={100,200,150,800,487,666,999, };
- cout<<"雜七雜八雜貨店價目表"<<endl;
- for(int a=0;a<7;a++){
-
- cout<<a+1<<"\t"<<m[a]<<"\t"<<n[a]<<"元"<<endl;
-
- }
- cout<<"8\t"<<m[7]<<endl;
- int o,q,s=0;
- re:
- cout<<endl<<"請輸入商品代碼:\t";
- cin>>o;
- if(o>0 && o<8){
- cout<<endl<<"請輸入商品數量:\t";
- cin>>q;
- s=s+(n[o-1]*q);
- goto re;
- }
- else if(o==8){
- goto checkout;}
- else{
- cout<<"輸入錯誤"<<endl;
- goto re;
- }
- checkout:
- cout<<"總共是:"<<s<<endl;
- system ("pause");
- return 0;
- }
複製代碼 |