返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     system("cls");
  8.     int j,f,sum=0;
  9.     string name[]={"遙控器車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    "};
  10.     int price[]={2000,2000,3250,20,6600,150,3800};
  11.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  12.     cout<<"[商品價目表]"<<endl;
  13.     for(int i=0; i<7; i++)
  14.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  15.     cout<<"(8)結帳"<<endl<<endl;
  16.     re2:
  17.     cout<<"請輸入商品代碼: ";
  18.     cin>>j;
  19.     if(j==8)
  20.     {
  21.         goto checkout;
  22.     }else if(j>=1 && j<=7)
  23.     {
  24.         cout<<"數量: ";
  25.         cin>>f;
  26.         sum+=price[j-1]*f;
  27.         goto re2;
  28.     }else
  29.     {
  30.         goto re;     
  31.     }
  32.     checkout:
  33.     cout<<endl<<"總共"<<sum<<"元!"<<endl;
  34.     system("pause");
  35.     goto re;
  36.     return 0;
  37. }
複製代碼

TOP

返回列表