本帖最後由 鄭豊翰 於 2024-6-22 11:37 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- { int a, b, c, sum;
- string product[7]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
- int price[7]={450,550,325,200,660,150,380};
- int qty[]={0,0,0,0,0,0,0};
-
- cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
- cout<<"[商品價目表]:"<<endl<<endl;
- for(int i=0; i<7; i++)
- cout<<"("<<i+1<<")"<<product[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<endl<<"(8)結帳"<<endl<<endl;
-
- re:
- cout<<"請輸入商品代碼: ";
- cin>>a;
- if(a>0 && a<=7){
- cout<<"數量;";
- cin>>b;
- sum += price[a-1]*b;
- qty[a-1]+=b;
- }
-
- else if(a==8){
- cout<<"[購物清單]"<<endl<<endl;
- cout<<"---------------------------"<<endl<<endl;
- for(int i=0; i<7; i++){
- if(qty[i]!=0){
- cout<<product[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
- }
- }
- cout<<"---------------------------"<<endl<<endl;
- cout<<sum<<endl;}
- goto re;
-
-
-
-
-
- system("pause");
- return 0;
- }
複製代碼 |