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

TOP

返回列表