日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

S1 商品信息管理系统

發布時間:2025/7/14 windows 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 S1 商品信息管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include <iostream> #include <cstdio> #include <cstdlib> #include <iomanip> #include <string> using namespace std; //void welcome();//歡迎界面 void display(int);//輸出信息 int size=0; class Product { public:void addProduct();void queryById();void queryByName();void queryByBrand();void queryByMode();void queryAll();void welcome();void find();void show();double setId(){return Id;}string setName(){return Name;}string setBrand(){return Brand;}string setMode(){return Mode;}double setprice(){return price;} private:int Id;string Name;string Brand;string Mode;double price; }; Product product[10000]; void Product::welcome() {int n,a;cout<<"*---------------------------*"<<endl;cout<<"|--------商品管理系統-------|"<<endl;cout<<"|---------------------------|"<<endl;cout<<endl;cout<<"|---------------------------|"<<endl;cout<<"|--------1.添加商品---------|"<<endl;cout<<"|--------2.查找商品---------|"<<endl;cout<<"|--------3.查找所有商品-----|"<<endl;cout<<"|--------4.退出系統---------|"<<endl;cout<<"*---------------------------*"<<endl;cout<<"請輸入指令:"<<endl;cin>>n;switch(n){case 1:Product::addProduct();Product::welcome();break;case 2:while(1){Product::find();cin>>a;if(a==1)Product::queryById();else if(a==2)Product::queryByName();else if(a==3)Product::queryByBrand();else if(a==4)Product::queryByMode();elseProduct::welcome();}break;case 3:Product::show();break;case 4:break;default:break;} } void Product::find() {cout<<"*---------------------------------*"<<endl;cout<<"|--------1.以圖書編號查找---------|"<<endl;cout<<"|--------2.以圖書名查找-----------|"<<endl;cout<<"|--------3.以作者名查找-----------|"<<endl;cout<<"|--------4.以出版社查找-----------|"<<endl;cout<<"|--------5.回到主菜單-------------|"<<endl;cout<<"*---------------------------------*"<<endl;cout<<"請輸入指令:";} void Product::addProduct() {char m;cout<<"輸入商品編號:";cin>>product[size].Id;cout<<"輸入商品名稱:";cin>>product[size].Name;cout<<"輸入商品品牌:";cin>>product[size].Brand;cout<<"輸入商品型號:";cin>>product[size].Mode;cout<<"輸入價格:";cin>>product[size].price;cout<<"加入成功!"<<endl;display(size);size++;cout<<"是否繼續加入圖書(是y,否n)"<<endl;cin>>m;if(m=='y')Product::addProduct();if(m=='n')Product::welcome(); } void display(int i) {cout<<"+-----------------------------------------------------------------------+"<<endl;cout<<setiosflags(ios::left)<<"+"<<setw(10)<<"商品編號"<<setw(10)<<"商品名稱"<<setw(10)<<"品牌"<<setw(10)<<"型號"<<setw(10)<<"價格"<<setw(3)<<"|"<<endl;cout<<"|-----------------------------------------------------------------------|"<<endl;cout<<setiosflags(ios::left)<<"|"<<setw(10)<<product[i].setId()<<setw(10)<<product[i].setName()<<setw(10)<<product[i].setBrand()<<setw(10)<<product[i].setBrand()<<setw(10)<<product[i].setprice()<<setw(3)<<"|"<<endl;cout<<"+-----------------------------------------------------------------------+"<<endl; } void Product::queryById() {int id;cout<<"輸入要查詢的商品編號:"<<endl;cin>>id;bool flag=false;int n;for(n=0; n<=size; n++)if(id==product[n].Id){flag=true;break;}if(flag)display(n);elsecout<<"無查詢結果!"<<endl; } void Product::queryByName() {string name;cout<<"輸入要查詢的商品名稱:"<<endl;cin>>name;bool flag=false;int n;for(n=0; n<=size; n++)if(name==product[n].Name){flag=true;break;}if(flag)display(n);elsecout<<"查無此商品!"<<endl; } void Product::queryByBrand() {string brand;cout<<"輸入要查詢的商品品牌:"<<endl;cin>>brand;int n;bool flag=false;for(n=0; n<=size; n++)if(brand==product[n].Brand){flag=true;break;}if(flag)display(n);elsecout<<"查無此商品!

"<<endl; } void Product::queryByMode() { string mode; cout<<"輸入要查詢的商品型號:"<<endl; cin>>mode; int n; bool flag=false; for(n=0; n<=size; n++) if(mode==product[n].Mode) { flag=true; break; } if(flag) display(n); else cout<<"查無此商品!

"<<endl; } void Product::show() { for(int n=0; n<size; n++) { display(n); } } int main() { Product p; p.welcome(); return 0; }

感悟:在上一個的基礎上 再做這個就相對easy多了!? 累的脖子疼 趴在床上編程序不easy啊。

轉載于:https://www.cnblogs.com/cxchanpin/p/6898673.html

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的S1 商品信息管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。