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

TOP

返回列表