返回列表 發帖
  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int buy[7];
  7.     int tim[7];
  8.     int total=0;
  9.     int num,many,time=0;
  10.     string name[7]={"(1)搖控汽車    ","(2)飛機模型    ","(3)足球        ","(4)拼圖        ","(5)玩具槍      ","(6)可愛玩偶    ","(7)籃球        "};
  11.     int price[7]={450,550,325,200,660,150,380};
  12.     cout<<"     智能玩具店"<<endl;
  13.     cout<<"[商品價目表]"<<endl;
  14.     for(int i=0;i<=6;i++)
  15.     {
  16.             cout<<name[i]<<price[i]<<"元";
  17.             cout<<endl;
  18.     }
  19.     cout<<"輸入(8)結帳"<<endl;
  20.     re:
  21.     while(true)
  22.     {
  23.                cout<<"請輸入商品代碼:  ";
  24.                cin>>num;
  25.                if(num==8)
  26.                break;
  27.                buy[time]=num;
  28.                cout<<"數量:  ";
  29.                cin>>many;
  30.                tim[time]=many;
  31.                total=total+(price[num-1]*many);
  32.                time++;
  33.     }
  34.     cout<<endl;
  35.     cout<<"[購物清單]"<<endl;
  36.     cout<<"--------------------------"<<endl;
  37.     for(int i=0;i<time;i++)
  38.     {
  39.             int j=0,k=0;
  40.             j=buy[i];
  41.             k=tim[i];
  42.             cout<<name[j]<<"    "<<price[j]<<"元 * "<<k<<"個"<<endl;
  43.     }
  44.     cout<<"--------------------------"<<endl;
  45.     cout<<"總共"<<total<<"元!"<<endl;
  46.     system("PAUSE");
  47.     return 0;
  48. }
複製代碼

TOP

  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int buy[7];
  7.     int tim[7];
  8.     int total=0;
  9.     int num,many,time=0,yes,money,give,give1000,give500,give100,give50,give10,give1,last;
  10.     string name[7]={"(1)搖控汽車    ","(2)飛機模型    ","(3)足球        ","(4)拼圖        ","(5)玩具槍      ","(6)可愛玩偶    ","(7)籃球        "};
  11.     int price[7]={450,550,325,200,660,150,380};
  12.     cout<<"     智能玩具店"<<endl;
  13.     cout<<"[商品價目表]"<<endl;
  14.     while(true)
  15.     {
  16.     for(int i=0;i<=6;i++)
  17.     {
  18.             cout<<name[i]<<price[i]<<"元";
  19.             cout<<endl;
  20.     }
  21.     cout<<"輸入(8)結帳"<<endl;
  22.     while(true)
  23.     {
  24.                cout<<"請輸入商品代碼:  ";
  25.                cin>>num;
  26.                if(num==8)
  27.                break;
  28.                buy[time]=num;
  29.                cout<<"數量:  ";
  30.                cin>>many;
  31.                tim[time]=many;
  32.                total=total+(price[num-1]*many);
  33.                time++;
  34.     }
  35.     cout<<endl;
  36.     cout<<"[購物清單]"<<endl;
  37.     cout<<"--------------------------------"<<endl;
  38.     for(int i=0;i<time;i++)
  39.     {
  40.             int j=0,k=0;
  41.             j=buy[i];
  42.             k=tim[i];
  43.             cout<<name[j]<<"    "<<price[j]<<"元 * "<<k<<"個"<<endl;
  44.     }
  45.     cout<<"-------------------------------"<<endl;
  46.     cout<<"總共"<<total<<"元!"<<endl;
  47.     cout<<endl;
  48.     cout<<"1-正確無誤 2-重新選購     ";
  49.     cin>>yes;
  50.     if(yes==1)
  51.     break;
  52.     }
  53.     while(true)
  54.     {
  55.     cout<<endl;
  56.     cout<<"請付帳:  ";
  57.     cin>>money;
  58.     if(money<total)
  59.     cout<<"您付的錢不夠,還差"<<total-money<<"元!"<<endl;
  60.     else
  61.     break;
  62.     }
  63.     if(money>total)
  64.     {
  65.         give=money-total;
  66.     }
  67.     if(give>1000)
  68.     {           
  69.     give1000=give/1000;
  70.     last=give%1000;
  71.     }
  72.     else if(last>500)
  73.     {
  74.          give500=last/500;
  75.          last=last%500;
  76.     }
  77.     else if(last>100)
  78.     {
  79.          give500=last/100;
  80.          last=last%100;
  81.     }
  82.     else if(last>50)
  83.     {
  84.          give500=last/50;
  85.          last=last%50;
  86.     }
  87.     else if(last>10)
  88.     {
  89.          give500=last/10;
  90.          last=last%10;
  91.     }
  92.     else if(last>1)
  93.     {
  94.          give500=last/1;
  95.          last=last%1;
  96.     }
  97.     cout<<"找您"<<give<<"元!"<<endl;
  98.     if(give1000!=0)
  99.     {
  100.            cout<<"一千元鈔票"<<give1000<<"張"<<endl;   
  101.     }
  102.     else if(give500!=0)
  103.     {
  104.            cout<<"五百元鈔票"<<give500<<"張"<<endl;   
  105.     }
  106.     else if(give100!=0)
  107.     {
  108.            cout<<"一百元鈔票"<<give100<<"張"<<endl;   
  109.     }
  110.     else if(give50!=0)
  111.     {
  112.            cout<<"五十元硬幣"<<give50<<"枚"<<endl;   
  113.     }
  114.     else if(give10!=0)
  115.     {
  116.            cout<<"五十元硬幣"<<give10<<"枚"<<endl;   
  117.     }
  118.     else if(give1!=0)
  119.     {
  120.            cout<<"五十元硬幣"<<give1<<"枚"<<endl;   
  121.     }
  122.    
  123.     system("PAUSE");
  124.     return 0;
  125. }
複製代碼

TOP

  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int total=0;
  7.     int num[100];
  8.     int many=0;
  9.     int time=0;
  10.     int yes=0;
  11.     int money=0;
  12.     int give=0;
  13.     int give1000=0,give500=0,give100=0,give50=0,give10=0,give1=0;
  14.     int last=0;
  15.     int buy[7];
  16.     int tim[7];
  17.     string name[7]={"(1)搖控汽車    ",
  18.                         "(2)飛機模型    ",
  19.                                         "(3)足球        ",
  20.                                         "(4)拼圖        ",
  21.                                         "(5)玩具槍      ",
  22.                                         "(6)可愛玩偶    ",
  23.                                         "(7)籃球        "};
  24.     int price[7]={450,
  25.                       550,
  26.                                   325,
  27.                                   200,
  28.                                   660,
  29.                                   150,
  30.                                   380};
  31.     cout<<"☆★☆智能玩具店☆★☆"<<endl;
  32.     cout<<"[商品價目表]"<<endl;
  33.     while(true)
  34.     {
  35.     for(int i=0;i<=6;i++)
  36.     {
  37.             cout<<name[i]<<price[i]<<"元";
  38.             cout<<endl;
  39.     }
  40.     cout<<"輸入(8)結帳"<<endl;
  41.     while(true)
  42.     {
  43.         cout<<"請輸入商品代碼:  ";
  44.         cin>>num;
  45.         if(num==8)
  46.         break;
  47.         buy[time]=num;
  48.         cout<<"數量:  ";
  49.         cin>>many;
  50.         tim[time]=many;
  51.         total=total+(price[num-1]*many);
  52.         time++;
  53.     }
  54.     cout<<endl;
  55.     cout<<"[購物清單]"<<endl;
  56.     cout<<"--------------------------------"<<endl;
  57.     for(int i=0;i<time;i++)
  58.     {
  59.         int j=0,k=0;
  60.         j=buy[i];
  61.         k=tim[i];
  62.         cout<<name[j-1]<<"    "<<price[j-1]<<"元 * "<<k<<"個"<<endl;
  63.     }
  64.     cout<<"-------------------------------"<<endl;
  65.     cout<<"總共"<<total<<"元!"<<endl;
  66.     cout<<endl;
  67.     while(true)
  68.     {
  69.     cout<<"1-正確無誤 2-重新選購     ";
  70.     cin>>yes;
  71.     if(yes==1)
  72.     break;
  73.     if(yes!=1||2)
  74.     cout<<"輸入錯誤請重新輸入"<<endl;
  75.         }
  76.         break;
  77.     }
  78.     while(true)
  79.     {
  80.     cout<<endl;
  81.     cout<<"請付帳:  ";
  82.     cin>>money;
  83.     if(money<total)
  84.     cout<<"您付的錢不夠,還差"<<total-money<<"元!"<<endl;
  85.     else
  86.     break;
  87.     }
  88.     give=money-total;
  89.     cout<<"找您"<<give<<"元!"<<endl;
  90.         if(give>=1000)
  91.         {           
  92.                 give1000=give/1000;
  93.                 last=give%1000;
  94.                         if(give1000>0)
  95.                         {
  96.                                 cout<<"一千元鈔票"<<give1000<<"張"<<endl;
  97.                         }       
  98.         }
  99.         else
  100.         {
  101.                 last=give;
  102.         }
  103.         if(last>=500)
  104.         {           
  105.                 give500=give/500;
  106.                 last=give%500;
  107.                         if(give500>0)
  108.                         {
  109.                                 cout<<"五百元鈔票"<<give500<<"張"<<endl;
  110.                         }
  111.         }
  112.         if(last>=100)
  113.         {
  114.                 give100=last/100;
  115.                 last=last%100;
  116.                     if(give100>0)
  117.                     {
  118.                             cout<<"一百元鈔票"<<give100<<"張"<<endl;
  119.                         }
  120.         }
  121.         if(last>=50)
  122.         {
  123.                 give50=last/50;
  124.                 last=last%50;
  125.                     if(give50>0)
  126.                     {
  127.                             cout<<"五十元硬幣"<<give50<<"枚"<<endl;
  128.                         }
  129.         }
  130.         if(last>=10)
  131.         {
  132.                 give10=last/10;
  133.                 last=last%10;
  134.                     if(give10>0)
  135.                     {
  136.                             cout<<"十元硬幣"<<give10<<"枚"<<endl;
  137.                         }
  138.         }
  139.         if(last>=1)
  140.         {
  141.                 give1=last/1;
  142.                 last=last%1;
  143.                     if(give>0)
  144.                     {
  145.                             cout<<"一元硬幣"<<give1<<"枚"<<endl;
  146.                         }
  147.         }
  148.     system("PAUSE");
  149.     return 0;
  150. }
複製代碼

TOP

  1. #include <cstdlib>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int total=0;
  7.     int num=0;
  8.     int many=0;
  9.     int time=0;
  10.     int yes=0;
  11.     int money=0;
  12.     int give=0;
  13.     int give1000=0,give500=0,give100=0,give50=0,give10=0,give1=0;
  14.     int last=0;
  15.     int buy[7];
  16.     int tim[7];
  17.     string name[7]={"(1)搖控汽車    ",
  18.                         "(2)飛機模型    ",
  19.                                         "(3)足球        ",
  20.                                         "(4)拼圖        ",
  21.                                         "(5)玩具槍      ",
  22.                                         "(6)可愛玩偶    ",
  23.                                         "(7)籃球        "};
  24.     int price[7]={450,
  25.                       550,
  26.                                   325,
  27.                                   200,
  28.                                   660,
  29.                                   150,
  30.                                   380};
  31.     cout<<"☆★☆智能玩具店☆★☆"<<endl;
  32.     cout<<"[商品價目表]"<<endl;
  33.     while(true)
  34.     {
  35.     for(int i=0;i<=6;i++)
  36.     {
  37.             cout<<name[i]<<price[i]<<"元";
  38.             cout<<endl;
  39.     }
  40.     cout<<"輸入(8)結帳"<<endl;
  41.     while(true)
  42.     {
  43.         while(true)
  44.         {
  45.             cout<<"請輸入商品代碼:  ";
  46.             cin>>num;
  47.             if(num==8)
  48.                 break;
  49.             if(num>8)
  50.                 cout<<"輸入錯誤請重新輸入"<<endl;
  51.             else
  52.                 break;
  53.         }
  54.         if(num==8)
  55.             break;
  56.         buy[time]=num;
  57.         cout<<"數量:  ";
  58.         cin>>many;
  59.         tim[time]=many;
  60.         total=total+(price[num-1]*many);
  61.         time++;
  62.     }
  63.     cout<<endl;
  64.     cout<<"[購物清單]"<<endl;
  65.     cout<<"--------------------------------"<<endl;
  66.     for(int i=0;i<time;i++)
  67.     {
  68.         int j=0,k=0;
  69.         j=buy[i];
  70.         k=tim[i];
  71.         cout<<name[j-1]<<"    "<<price[j-1]<<"元 * "<<k<<"個"<<endl;
  72.     }
  73.     cout<<"-------------------------------"<<endl;
  74.     cout<<"總共"<<total<<"元!"<<endl;
  75.     cout<<endl;
  76.     if(total>=3000)
  77.     {
  78.         cout<<"由於消費滿三千送炫光溜溜球乙個"<<endl;
  79.     }
  80.     if(total>=10000)
  81.     {
  82.         cout<<"由於消費滿萬送千元折價券"<<endl;
  83.     }
  84.     if(total>=1000)
  85.     {
  86.         cout<<"由於滿五千享9折優惠,只要付"<<total*0.9<<"元"<<endl;
  87.     }
  88.     while(true)
  89.     {
  90.     cout<<"1-正確無誤 2-重新選購     ";
  91.     cin>>yes;
  92.     if(yes==1)
  93.     break;
  94.     if(yes!=1||2)
  95.     cout<<"輸入錯誤請重新輸入"<<endl;
  96.         }
  97.         break;
  98.     }
  99.     while(true)
  100.     {
  101.     cout<<endl;
  102.     cout<<"請付帳:  ";
  103.     cin>>money;
  104.     if(money<total)
  105.     cout<<"您付的錢不夠,還差"<<total-money<<"元!"<<endl;
  106.     else
  107.     break;
  108.     }
  109.     give=money-total;
  110.     cout<<"找您"<<give<<"元!"<<endl;
  111.         if(give>=1000)
  112.         {
  113.                 give1000=give/1000;
  114.                 last=give%1000;
  115.                         if(give1000>0)
  116.                         {
  117.                                 cout<<"一千元鈔票"<<give1000<<"張"<<endl;
  118.                         }
  119.         }
  120.         else
  121.         {
  122.                 last=give;
  123.         }
  124.         if(last>=500)
  125.         {
  126.                 give500=last/500;
  127.                 last=give%500;
  128.                         if(give500>0)
  129.                         {
  130.                                 cout<<"五百元鈔票"<<give500<<"張"<<endl;
  131.                         }
  132.         }
  133.         if(last>=100)
  134.         {
  135.                 give100=last/100;
  136.                 last=last%100;
  137.                     if(give100>0)
  138.                     {
  139.                             cout<<"一百元鈔票"<<give100<<"張"<<endl;
  140.                         }
  141.         }
  142.         if(last>=50)
  143.         {
  144.                 give50=last/50;
  145.                 last=last%50;
  146.                     if(give50>0)
  147.                     {
  148.                             cout<<"五十元硬幣"<<give50<<"枚"<<endl;
  149.                         }
  150.         }
  151.         if(last>=10)
  152.         {
  153.                 give10=last/10;
  154.                 last=last%10;
  155.                     if(give10>0)
  156.                     {
  157.                             cout<<"十元硬幣"<<give10<<"枚"<<endl;
  158.                         }
  159.         }
  160.         if(last>=1)
  161.         {
  162.                 give1=last/1;
  163.                 last=last%1;
  164.                     if(give>0)
  165.                     {
  166.                             cout<<"一元硬幣"<<give1<<"枚"<<endl;
  167.                         }
  168.         }
  169.     system("PAUSE");
  170.     return 0;
  171. }
複製代碼

TOP

返回列表