- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int c=0,sum=0,h;
- int n[7]={450,550,325,200,660,150,380};
- string s[7]={"遙控器車","飛機模型","足球 ","拼圖 ","玩具槍","可愛玩偶","籃球 "};
- cout<<"***智能玩具店***"<<endl;
- cout<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0;i<7;i++)
- {
- cout<<"<"<<i+1<<">"<<s[i]<<"\t"<<n[i]<<endl;
- }
- cout<<"(8)結帳"<<endl;
- re:
- cout<<"請輸入商品代碼:";
- cin>>c;
- if (c>=1 && c<=7)
- {
- cout<<"數量:";
- cin>>h;
- if(h>0)
- {
- sum+=n[c-1]*h;
- }else
- {
- cout<<"錯誤"<<endl;
- }
-
- goto re;
- }else if(c==8)
- {
- cout<<"總共:"<<sum<<endl;
- }else
- {
- cout<<"輸入失敗"<<endl;
- goto re;
- }
-
-
-
- system("pause");
- return 0;
-
- }
複製代碼 |