- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string a[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
- int c[]={450,550,325,200,660,150,380};
- cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int b=0;b<7;b++){
- cout<<"("<<b+1<<")"<<a[b]<<"\t"<<c[b]<<endl;
- }
- cout<<"(8)結帳"<<endl<<endl;
- int f,g,h=0;
- re:
- cout<<"請輸入商品代碼,輸入完畢後,請按Enter鍵";
- cin>>f;
- if(f>=1 and f<=7){
- cout<<"請輸入數量:";
- cin>>g;
- h=h+c[f-1]*g;
- goto re;
- }
- else if(f==8){
- goto re2;
- }
- else{
- cout<<"輸入錯誤"<<endl;
- }
- re2:
- cout<<"一共"<<h<<"元"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |