返回列表 發帖
  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.     int price[]={450,550,325,200,660,150,380};
  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.     while(true)
  17.     {
  18.         cout<<"請輸入商品編號: ";
  19.         cin>>p;
  20.         if(p==8)
  21.             break;
  22.         cout<<"請問要買幾個: ";
  23.         cin>>q;
  24.         sum+=price[p]*q;
  25.     }
  26.     cout<<sum<<endl;        
  27.     system("pause");
  28.     goto re;   
  29.     return 0;
  30. }
複製代碼
Huang chenhao

TOP

返回列表