返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int BUY[7];
  7.     string name[7]=
  8.        {  
  9.           "(1)搖控汽車  ",
  10.           "(2)玩具車    ",
  11.           "(3)遙控直升機",
  12.           "(4)足球      ",
  13.           "(5)籃球      ",
  14.           "(6)棒球      ",
  15.           "(7)玩具熊    "
  16.        };
  17.     int num[7]=
  18.        {
  19.                500 ,
  20.                1000,
  21.                540 ,
  22.                450 ,
  23.                660 ,
  24.                5   ,
  25.                10  
  26.        };
  27.     int index = 0;
  28.     cout<<"玩具店"<<endl;
  29.     cout<<"價目表"<<endl;
  30.     for(int i=0;i<7;i++)
  31.     {
  32.     cout<<name[i]<<num[i]<<endl;
  33.     }
  34.          cout<<endl;
  35.          int productnumber=0;
  36.          int count=0;
  37.          int total=0;
  38.          cout<<"輸入-1離開"<<endl;

  39.     while (true)
  40.     {

  41.     cout<<"請輸入商品代碼"<<endl;
  42.     cin>>productnumber;
  43.     if(productnumber==-1)
  44.     {
  45.       break;
  46.     }
  47.     BUY[index] = productnumber;
  48.     cout<<"請輸入數量"<<endl;
  49.     cin>>count;
  50.     index++;
  51.     }
  52.     total=total+(num[count-1]*count);
  53.     cout<<"[購物清單]"<<endl;
  54.     cout<<"----------------------"<<endl;
  55.     for(int i=0;i<index;i++)
  56.     {
  57.     cout<<name[BUY[i]-1]<<endl;
  58.     }
  59.     cout<<"----------------------"<<endl;
  60.     cout<<"總金額為"<<total;
  61.     system("pause");
  62.     return 0;
  63. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int BUY[7];
  7.     int Buycout[7];
  8.     string name[7]=
  9.        {  
  10.           "(1)搖控汽車  ",
  11.           "(2)玩具車    ",
  12.           "(3)遙控直升機",
  13.           "(4)足球      ",
  14.           "(5)籃球      ",
  15.           "(6)棒球      ",
  16.           "(7)玩具熊    "
  17.        };
  18.     int num[7]=
  19.        {
  20.                500 ,
  21.                1000,
  22.                540 ,
  23.                450 ,
  24.                660 ,
  25.                5   ,
  26.                10  
  27.        };
  28.     int index = 0;
  29.     cout<<"玩具店"<<endl;
  30.     cout<<"價目表"<<endl;
  31.     for(int i=0;i<7;i++)
  32.     {
  33.     cout<<name[i]<<num[i]<<endl;
  34.   
  35.     }
  36.          cout<<endl;
  37.          int productnumber=0;
  38.          int count=0;
  39.          int total=0;
  40.          cout<<"輸入-1離開"<<endl;

  41.     while (true)
  42.     {

  43.     cout<<"請輸入商品代碼"<<endl;
  44.     cin>>productnumber;
  45.     if(productnumber==-1)
  46.     {
  47.       break;
  48.     }
  49.     BUY[index] = productnumber;
  50.     cout<<"請輸入數量"<<endl;
  51.     cin>>count;
  52.     Buycout[index] = count;
  53.     index++;
  54.     }
  55.     total=total+(num[count-1]*count);
  56.     cout<<"[購物清單]"<<endl;
  57.     cout<<"----------------------"<<endl;
  58.     for(int i=0;i<index;i++)
  59.     {
  60.     cout<<name[BUY[i]-1]<<"\t"<<num[BUY[i]-1]<<"元 *"<<Buycout[i]<<endl;
  61.     }
  62.     cout<<"----------------------"<<endl;
  63.     cout<<"總金額為"<<total;
  64.     system("pause");
  65.     return 0;
  66. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int BUY[7];
  7.     int Buycout[7];
  8.     string name[7]=
  9.        {  
  10.           "(1)搖控汽車  ",
  11.           "(2)玩具車    ",
  12.           "(3)遙控直升機",
  13.           "(4)足球      ",
  14.           "(5)籃球      ",
  15.           "(6)棒球      ",
  16.           "(7)玩具熊    "
  17.        };
  18.     int num[7]=
  19.     {
  20.                500 ,
  21.                1000,
  22.                540 ,
  23.                450 ,
  24.                660 ,
  25.                5   ,
  26.                10  
  27.     };
  28.     int index = 0;
  29.     cout<<"玩具店"<<endl;
  30.     cout<<"價目表"<<endl;
  31.     for(int i=0;i<7;i++)
  32.     {
  33.     cout<<name[i]<<num[i]<<endl;
  34.   
  35.     }
  36.     cout<<endl;
  37.     int jiaho=0;
  38.     int productnumber=0;
  39.     int count=0;
  40.     int total=0;
  41.     int number=0;
  42.     cout<<"輸入-1離開"<<endl;
  43.     while(true)
  44. {
  45.     while(true)
  46.     {
  47.     cout<<"請輸入商品代碼"<<endl;a
  48.     cin>>productnumber;
  49.     if(productnumber==-1)
  50.     {
  51.       break;
  52.     }
  53.     BUY[index] = productnumber;
  54.     cout<<"請輸入數量"<<endl;
  55.     cin>>count;
  56.     Buycout[index] = count;
  57.     index++;
  58.     total=total+(num[productnumber-1]*count);
  59.     }
  60.    
  61.     cout<<"繼續購買? (1)要 (2)不要"<<endl;
  62.     cin>>jiaho;
  63.     if(jiaho==1)
  64.     {
  65.     continue;            
  66.     }
  67.     else
  68.     {
  69.     cout<<"[購物清單]"<<endl;
  70.     cout<<"----------------------"<<endl;
  71.     for(int i=0;i<index;i++)
  72.     {
  73.     cout<<name[BUY[i]-1]<<"\t"<<num[BUY[i]-1]<<"元 *"<<Buycout[i]<<endl;
  74.     }
  75.     cout<<"----------------------"<<endl;
  76.     cout<<"總金額為"<<total;
  77.     }
  78. }   
  79.     system("pause");
  80.     return 0;
  81. }
複製代碼

TOP

返回列表