返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     system("cls");
  8.     int p,q,sum=0;
  9.     string name[]={"布加迪凱龍,BMW M4,東迎戰神GTR,麥拉倫,保時捷,瑪莎拉蒂,藍寶堅尼"};
  10.     int price[]={455100000,55000052,32045500,20000045,66000254,15005460,38678460};
  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>>p;
  19.     }else if(p>=1 && p<=7)
  20.     {
  21.         cout<<"數量: ";
  22.         cin>>q;
  23.         sum+=price[p-1]*q;
  24.         goto re2;  
  25.     }else
  26.     {
  27.         goto re;     
  28.     }
  29.     checkout:
  30.     cout<<endl<<"總共"<<sum<<"元!"<<endl;         
  31.     system("pause");
  32.     goto re;   
  33.     return 0;
  34. }
複製代碼

TOP

返回列表