返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int buy[7];
  7.      int buya[7];
  8.     cout<<"智能玩具店"<<endl;
  9.     string num[7]={"(1)遙控車","(2)遙控飛機","(3)足球  ","(4)拼圖  ","(5)籃球  ","(6)玩具槍","(7)娃娃"};
  10.     int n[7]={750,550,555,78,885,1999,85};
  11.     for(int i=0;i<7;i++)
  12.     {
  13.       cout<<num[i]<<"\t";     
  14.       cout<<n[i]<<"\t";
  15.       cout<<endl;
  16.     }
  17.     int a=0;
  18.     int z=0;
  19.     int w=0;
  20.     int index=0;
  21.      cout<<"輸入-1離開:"<<endl;
  22.      while(true)
  23.      {
  24.     cout<<"商品代碼:"<<endl;
  25.     cin>>a;
  26.     if(a==-1)
  27.     {
  28.     break;
  29.     }
  30.     buy[index]=a;
  31.     cout<<"數量:"<<endl;
  32.     cin>>z;
  33.     buya[index]=z;
  34.     w= w+n[a-1]*z;
  35.     index++;
  36.     }
  37.    
  38.     cout<<"購物清單"<<endl;
  39.     cout<<"--------------------"<<endl;
  40.     for(int i=0;i<index;i++)
  41.     {
  42.      cout<<num[buy[i]-1]<<"\t"<<n[buy[i]-1]<<"元*"<<buya[i]<<"個" <<endl;
  43.      
  44.     }
  45.     cout<<"--------------------"<<endl;
  46.      cout<<"總金額:"<<w<<endl;
  47.     system("pause");
  48.      return 0;     
  49. }
複製代碼

TOP

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int buy[7];
  7.      int buya[7];
  8.     cout<<"智能玩具店"<<endl;
  9.     string num[7]={"(1)遙控車","(2)遙控飛機","(3)足球  ","(4)拼圖  ","(5)籃球  ","(6)玩具槍","(7)娃娃"};
  10.     int n[7]={750,550,555,78,885,1999,85};
  11.     for(int i=0;i<7;i++)
  12.     {
  13.       cout<<num[i]<<"\t";     
  14.       cout<<n[i]<<"\t";
  15.       cout<<endl;
  16.     }
  17.     int a=0;
  18.     int z=0;
  19.     int w=0;
  20.     int index=0;
  21.     int number=0;
  22.      cout<<"輸入-1離開:"<<endl;
  23.      while(true)
  24.      {
  25.      while(true)
  26.      {
  27.     cout<<"商品代碼:"<<endl;
  28.     cin>>a;
  29.     if(a==-1)
  30.     {
  31.     break;
  32.     }
  33.     buy[index]=a;
  34.     cout<<"數量:"<<endl;
  35.     cin>>z;
  36.     buya[index]=z;
  37.     w= w+n[a-1]*z;
  38.     index++;
  39.     }
  40.     cout<<"是否購買(1)是(2)不要"<<endl;
  41.     cin>> number;
  42.     if(number==1)
  43.     {continue;
  44.     }
  45.     }
  46.    else
  47.    {
  48.     cout<<"購物清單"<<endl;
  49.     cout<<"--------------------"<<endl;
  50.     for(int i=0;i<index;i++)
  51.     {
  52.      cout<<num[buy[i]-1]<<"\t"<<n[buy[i]-1]<<"元*"<<buya[i]<<"個" <<endl;
  53.      
  54.     }
  55.     cout<<"--------------------"<<endl;
  56.      cout<<"總金額:"<<w<<endl;
  57.     }
  58.     system("pause");
  59.      return 0;     
  60. }
複製代碼

TOP

返回列表