返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     string a[]={"遙控汽車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    "};
  7.     int c[]={450,550,325,200,660,150,380};
  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  9.     cout<<"[商品價目表]"<<endl;           
  10.     for(int b=0;b<7;b++){
  11.       cout<<"("<<b+1<<")"<<a[b]<<"\t"<<c[b]<<endl;
  12.             }
  13.     cout<<"(8)結帳"<<endl<<endl;
  14.     int f,g,h=0;
  15.     re:
  16.     cout<<"請輸入商品代碼,輸入完畢後,請按Enter鍵";
  17.     cin>>f;
  18.     if(f>=1 and f<=7){
  19.     cout<<"請輸入數量:";
  20.     cin>>g;
  21.     h=h+c[f-1]*g;
  22.     goto re;
  23.             }
  24.     else if(f==8){
  25.     goto re2;
  26.          }
  27.     else{
  28.     cout<<"輸入錯誤"<<endl;
  29.          }
  30.     re2:
  31.         cout<<"一共"<<h<<"元"<<endl;
  32.     system("pause");
  33.     return 0;
  34. }
複製代碼

TOP

返回列表