返回列表 發帖
  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[]={"黃色飛機 ","金正恩模型","笑氣    ","手槍   ","充氣玩偶",
  10.     "籃鳥    ","核彈  ","雄商飛彈"};
  11.     int price[]={1233,666,999,2150,2999,799,9500,4987};
  12.     cout<<"☆★☆畸形軍火庫☆★☆"<<endl<<endl;
  13.     cout<<"[商品價目表]"<<endl;
  14.     for(int i=0; i<8; i++)
  15.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  16.         cout<<"(9)結帳"<<endl<<endl;
  17.     re2:
  18.     cout<<"請輸入商品代碼: ";
  19.     cin>>p;
  20.     if(p==9)
  21.     {
  22.         goto checkout;
  23.     }else if(p>=1 && p<=8)
  24.     {
  25.         cout<<"數量: ";
  26.         cin>>q;
  27.         sum+=price[p-1]*q;
  28.         goto re2;  
  29.     }else
  30.     {
  31.         goto re;     
  32.     }
  33.     checkout:
  34.     cout<<endl<<"總共"<<sum<<"元!"<<endl;         
  35.     system("pause");
  36.     goto re;   
  37.     return 0;
  38. }
複製代碼

TOP

返回列表