返回列表 發帖

購物系統 (一)

本帖最後由 鄭繼威 於 2023-4-28 20:19 編輯

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

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

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

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

TOP

  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};
  8.    
  9.     cout<<"智能玩具店"<<endl<<endl;
  10.     cout<<"商品價目表"<<endl;
  11.    
  12.     for(int i=0;i<=4;i++)
  13.        cout<<"["<<i+1<<"]"<<name[i]<<"\t"<<price[i]<<endl;
  14.    
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

本帖最後由 黃子豪 於 2023-4-28 20:27 編輯
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     string name[]={"遙控汽車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    "};
  5.     int price[]={450,550,325,200,660,150,380};
  6.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  7.     cout<<"[商品價目表]"<<endl;

  8.     for(int i=0; i<7; i++){
  9.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;        
  10.     }
  11.    
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

本帖最後由 呂宗晉 於 2023-5-17 19:21 編輯
  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<=6;i++)
  11.     {
  12.            cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<endl;
  13.      }
  14.    
  15.    
  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

TOP

3

TOP

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.   string name[]={"R/C Car", "Model Plane", "Football", "Tennis Ball","Toy Gun","Basketball"};
  6.   int price[]={400,690,678,560,570,300};
  7.   cout<<"*****Da Epic Toy Store*****"<<endl<<endl;
  8.   cout<<"[Products]"<<endl;
  9.   
  10.   for(int i=0;i<=5;i++)
  11.   {
  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.     string names[3]={"餅乾","糖果","飲料"};
  6.     int price[3]={5,10,15};
  7.     for(int i=0;i<=2;i++){
  8.             cout<<i+1<<names[i]<<"\t"<<price[i]<<"\n";
  9.     }
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

  1. #include<cstdlib>
  2. #include<iostream>
  3. using namespace std;
  4. int main(){
  5. string m[7]={"兔子布偶","文具組合","高級餅乾","鍵盤滑鼠","遊戲點數","藍色外套","神秘獎品"};
  6. int n[7]={100,200,150,800,487,666,999};
  7. cout<<"雜七雜八雜貨店價目表"<<endl;
  8. for(int a=0;a<7;a++){
  9.         
  10.         cout<<a+1<<"\t"<<m[a]<<"\t"<<n[a]<<"元"<<endl;
  11.         
  12.         }
  13.         

  14. system ("pause");
  15. return 0;
  16. }
複製代碼
Attention Seeker </3

TOP

本帖最後由 盧玄皓 於 2023-4-28 20:28 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string n[]={"手槍      ","彈藥        ","98K      ","AWM       ","M500       ","沙漠之鷹      "};
  7.    
  8.    int price[]={10000,450,98000,100000,43000,52000};
  9.    
  10.      cout<<"fire槍械店"<<endl<<endl;
  11.    cout<<"[槍械價目表]"<<endl;
  12.    for(int i=0;i<6;i++)
  13.     {
  14.             cout<<"("<<i+1<<")"<<n[i]<<"\t"<<price[i]<<endl;
  15.         }
  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

TOP

本帖最後由 呂得銓 於 2023-5-17 19:26 編輯
  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<=6;i++)
  11.     {
  12.        cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<endl;
  13.     }  
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

TOP

9

TOP

  1. #include<iostream>
  2. using namespace std;
  3. int main(){

  4.     string name[]={"傷藥","解麻藥","好傷藥","寶貝球","高級球"};
  5.     int  price[]={200,400,500,200,800};
  6.         cout<<"   寶可夢商店   "<<endl<<endl;  
  7.     cout<<"[商品價格表]"<<endl;
  8.    
  9.     for(int i=0; i<5; i++)
  10.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  11.    
  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[]={50,75,60,75,30,};
  8.       
  9.         cout<<"☆★☆智能飲料店☆★☆"<<endl<<endl;
  10.     cout<<"[商品價目表]"<<endl;
  11.     for(int i=0;i<=4;i++)
  12.     {
  13.             cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<endl;
  14.         }
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

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

TOP

返回列表