資源簡介
C++大實驗
C++大作業
調用了很多系統函數
模擬超市收銀系統的所有功能
支持注冊、登陸
支持打印小票
支持VIP和會員管理
支持財務統計

代碼片段和文件信息
#include?????????????????????
#include
#include
#include
#include
#include
using?namespace?std;
string?td;
class?Product???????????????????//商品類
{private:?????????????????????//私有數據成員
double?price;????????????????
????char?name[30][30];
????string??number;
public:?
//成員函數
void?addproduct();??????????????????//增加商品
void?search(); //查找商品信息
void?change(); //?更改商品信息
void?display();??????????????????????//顯示商品信息
int?del(int?k=0);?????????????????????//刪除商品信息
};
void??Product::addproduct()??????????????????//增加商品??
{???double?price;
????string?namname;
int?k=0;
cout<<“請?輸?入?商?品?條?形?碼?:?“;
cin>>number;
nam=“D:\\商品\\“+number+“.txt“;
ifstream?infile(nam.c_str());
if(infile)
{
cout<<“????????????????????該商品已存在請重新選擇!“< k=1;
infile.close();
}
infile.close();
if(k==0)
{
ofstream?outfile(nam.c_str());
if(!outfile)
{
cout<<“?????????????????????系統出現錯誤,請重新保存!“< }
if(outfile)
{
outfile< cout<<“請?輸?入?商?品?價?格?:“;
cin>>price;?
outfile< cout<<“請?輸?入?商?品?名??:“;
cin>>name;
outfile< outfile.close();
cout<<“????????????????保存商品成功!“< }
}
}
void?Product::search()?????????????//查找商品信息
{
string?nam;
cout<<“請?輸?入?商?品?條?形?碼:?“;
cin>>number;
nam=“D:\\商品\\“+number+“.txt“;
ifstream?infile(nam.c_str());
if(!infile)
{
cout<<“ 未找到該商品,請核對?!“< }
else
{
cout<<“??????????????????該商品存在,詳情請查詢所有信息?!“< infile.close();
}
}
void?Product::change()????????????//?更改商品信息
{
string?pnumbernamname;
double?price;
int?m=0;
????m=del(1);
if(m==1)
{
cout<<“?????????????????????????請?輸?入?更?改?后?的?商?品?信?息?!“< cout<<“???????????????????????????????商?品?條?形?碼?:?“;
cin>>number;
nam=“D:\\商品\\“+number+“.txt“;
ofstream?outfile(nam.c_str());
if(outfile)
{?
cout<<“???????????????????????????????商?品?名?:?“;
cin>>name;
cout<<“???????????????????????????????商?品?價?格?:?“;
cin>>price;
outfile< outfile< outfile< outfile.close();
}
}
}
void?Product::display()??????????????????????//顯示商品信息
{
string?nam;
cout<<“請?輸?入?要?查?找?商?品?條?形?碼?:“;
cin>>number;
nam=“D:\\商品\\“+number+“.txt“;
ifstream?infile(nam.c_str());
if(!infile)
{
cout<<“ ?該商品不存在,請核對!“< }
else
{
cout<<“ ??該商品存在!商品信息如下:“< string?s;
while(getline(infiles))
{
cout< }
}
infile.close();
}
int?Product::del(int?k)?????????????????????//刪除商品信息
{
????string?pnumbernam;
????cout<<“請?輸?入?商?品?條?形?碼?:?“;
????cin>>pnumber;
nam=“D:\\商品\\“+pnumber+“.txt“;
????ifstream?infile(nam.c_str());
?if(!infile)
?{
? cout<<“ 該商品不存在,請核對!“<
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-04-20?08:54??編譯文件全\
?????文件???????28447??2012-06-13?15:55??編譯文件全\C++牛中超組.cpp
?????文件????????3463??2012-06-13?15:52??編譯文件全\C++牛中超組.dsp
?????文件?????????530??2012-06-13?15:56??編譯文件全\C++牛中超組.dsw
?????文件???????41984??2012-06-13?15:56??編譯文件全\C++牛中超組.ncb
?????文件???????48640??2012-06-13?15:56??編譯文件全\C++牛中超組.opt
?????文件?????????771??2012-06-13?15:55??編譯文件全\C++牛中超組.plg
?????目錄???????????0??2014-04-20?08:54??編譯文件全\Debug\
?????文件??????663616??2012-06-13?15:55??編譯文件全\Debug\C++牛中超組.exe
?????文件??????889768??2012-06-13?15:55??編譯文件全\Debug\C++牛中超組.ilk
?????文件??????560275??2012-06-13?15:55??編譯文件全\Debug\C++牛中超組.obj
?????文件?????5509020??2012-06-13?15:52??編譯文件全\Debug\C++牛中超組.pch
?????文件?????1238016??2012-06-13?15:55??編譯文件全\Debug\C++牛中超組.pdb
?????文件??????304128??2012-06-13?15:55??編譯文件全\Debug\vc60.idb
?????文件??????143360??2012-06-13?15:55??編譯文件全\Debug\vc60.pdb
- 上一篇:Simple算法算例
- 下一篇:數據結構(C++版) 唐寧九
評論
共有 條評論