返回列表 發帖

購物系統 (一)

本帖最後由 鄭繼威 於 2022-11-23 19:34 編輯

運用陣列技巧,設計一購物系統的商品價目表,商店名稱商品價格 請同學們發揮創意自由發揮

提示:宣告兩個一維陣列,分別裝商品名稱商品價格

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"遙控汽車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    "};
  7.     int price[]={450,550,325,200,660,150,380};
  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  9.     cout<<"[商品價目表]"<<endl;
  10.     for(int i=0; i<7; i++)
  11.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {      
  6.     string name[]={"遙控汽車","飛機模型","足球","拼圖","玩具槍","可愛玩偶","籃球"};
  7.     int price[]={40,50,25,20,60,15,30};
  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  9.     cout<<"[商品價目表]"<<endl;
  10.     for(int i=0;i<7;i++)
  11.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"遙控人","大鳥機模型","人肉球","拼身體"};
  7.     int price[]={2000,660,1256,1000};
  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  9.     cout<<"[商品價目表]"<<endl;
  10.     for(int i=0; i<4; i++)
  11.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"$"<<endl;
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {      
  6.    string name[]={"遙控汽車","飛機模型","足球    "};
  7.    
  8.    int price[]={0,0,0};
  9.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  10.     cout<<"[商品價目表]"<<endl;
  11.     for(int i=0; i<7; i++)
  12.             cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  13.    
  14.    
  15. system("pause");
  16. return 0;   
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {      
  6.     string name[]={"模型","拼圖","玩偶","球"};
  7.     int price[]={400,300,200,100};
  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl;
  9.     cout<<"[商品價目表]"<<endl;
  10.     for(int i=0; i<4; i++)
  11.     {
  12.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<endl;
  13.     }
  14.     system("pause");
  15.     return 0;   
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     string name[]={"switch","ps5","ps4 ","紅白機","DS","手機","平板"};
  6.     int price[]={320,350,370,390,410,470,490};
  7.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  8.     cout<<"[商品價目表]"<<endl;
  9.     for(int i=0; i<7; i++)
  10.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  11.     system("pause");
  12.     return 0;
  13. }
複製代碼

TOP

返回列表