C + + 课程设计之服装信息管理系统。①代码分析(含有源码)
生活随笔
收集整理的這篇文章主要介紹了
C + + 课程设计之服装信息管理系统。①代码分析(含有源码)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文件包含?
頭文件
#include<iostream> #include<string> #include<stdlib.h> #include<conio.h> #include<windows.h> #include<fstream> using namespace std;// boss類 class VIP { public:int vnum; // boss號string name; // boss姓名int num; //服裝編號string bookName; //服裝名string author; //設(shè)計者?string press; //出版社VIP *next; //指針};//服裝結(jié)點類 class Node { public:int num; //服裝編號float prize;string bookName; //服裝名string author; //設(shè)計者?string press; //出版社Node *next; //指針 int times = 0; //計數(shù)器 };VIP vip[100]; Node book[100]; int times=0;void BookSysterm(); //系統(tǒng)管理void SaveData(); //保存數(shù)據(jù)void OpenData(); //打開數(shù)據(jù) void Index(); //首頁void BookInterface(); //服裝管理界面void VIPInterface(); // boss管理界面void DeleteBook(); //刪除服裝函數(shù)void LookupBookIn(); //服裝查詢頁面void LookupVIPIn();// boss查詢頁面 void add(); //增加服裝函數(shù)void Output(Node p); //輸出服裝信息函數(shù)int LookupBook(); //通過服裝名查找void LookupAuthor(); //通過設(shè)計者?名查找int LookupNum(); //通過編號查找void LookupPress(); //通過出版社查找 void addVIP(); //增加 boss函數(shù)void OutputVIP(VIP s); //輸出 boss信息函數(shù)int LookupNumVIP(); //按編號查詢 bossvoid LookupNameVIP(); //按 boss姓名查找 bossvoid DeleteVIPbook(); //刪除 boss借服裝信息void Delete(); //刪除 boss函數(shù)void Query(); //根據(jù) boss編號查詢借服裝信息void Return(); //還服裝函數(shù)void Borrow(); //服裝借閱函數(shù).cpp文件
#include <iostream>#include"yifu.h"#include<windows.h> #include<fstream> using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) {cout<<"/t/t/t進入系統(tǒng)中"; for (int i = 0; i < 10; i++) {Sleep(10); //需要#include<windows.h> cout << ".";}system("cls");Index(); //首頁函數(shù)return 0;}//增加 服裝函數(shù) void add() {for (int i = 0; i < 100; i++) {if (book[i].num == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝編號:";cin >> book[i].num;cout << endl;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝名:";cin >> book[i].bookName;cout << endl;cout << "\t" << "\t" << "\t" << "\t" << "請輸入設(shè)計師:";cin >> book[i].author;cout << endl;cout << "\t" << "\t" << "\t" << "\t" << "請輸入品牌:";cin >> book[i].press;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝價格:";cin >> book[i].prize;cout << "\n" << "\t" << "\t" << "\t" << "\t" << " 服裝添加成功" << "\n" << endl;break;}times++;}return; }//刪除 服裝函數(shù) void DeleteBook() {int b = LookupNum();book[b].author = '\0';book[b].bookName = '\0';book[b].num = 0;book[b].press = '\0';book[b].prize = 0;cout << "\n" << "\t" << "\t" << "\t" << "\t" << " 服裝刪除成功" << endl; }//輸出 服裝信息函數(shù) void Output(int b) {for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n";cout << "\t" << "\t" << "\t" << "\t" << " | 服裝編號:" << book[b].num << " | 服裝名:" << book[b].bookName << " | 設(shè)計師:" <<book[b].author << " | 品牌:" << book[b].press <<" | 價格"<<book[b].prize <<endl;for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n";} void print( ) {int b; for ( b= 0; b<10;b++){for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n";cout << "\t" << "\t" << "\t" << "\t" << " | 服裝編號:" << book[b].num << " | 服裝名:" << book[b].bookName << " | 設(shè)計師:" <<book[b].author << " | 品牌:" << book[b].press <<" | 價格"<<book[b].prize <<endl;}for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n"; } //通過 服裝名查找 int LookupBook() {int j = 0;string bookname;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝名:";cin >> bookname;for (int i = 0; i < 100; i++) {if (book[i].bookName == bookname) {j = 1;Output(i);return i;}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 服裝" << "\n" << endl;}return 1000; }//通過設(shè)計師名查找 void LookupAuthor() {int j = 0;string author;cout << "\t" << "\t" << "\t" << "\t" << "請輸入設(shè)計師姓名:";cin >> author;for (int i = 0; i < 100; i++) {if (book[i].author == author) {j = 1;Output(i);}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 服裝" << "\n" << endl;} }//通過編號查找 int LookupNum() {int j = 0;int num;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝編號:";cin >> num;for (int i = 0; i < 100; i++) {if (book[i].num == num) {j = 1;Output(i);return i;}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 服裝" << "\n" << endl;}return 1000; }//通過品牌查找 void LookupPress() {int j = 0;string press;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 服裝品牌:";cin >> press;for (int i = 0; i < 100; i++) {if (book[i].press == press) {j = 1;Output(i);break;}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 服裝" << "\n" << endl;} }//增加 boss函數(shù) void addVIP() {for (int i = 0; i < 100; i++) {if (vip[i].vnum == 0) {cout << "\t" << "\t" << "\t" << "\t" << "請輸入 boss編號:";cin >> vip[i].vnum;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 boss名:";cin >> vip[i].name;cout << "\t" << "\t" << "\t" << "\t" << " boss添加成功" << "\n" << endl;break;}} }//輸出 boss信息函數(shù) void OutputVIP(int s) {for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n";cout << "\t" << "\t" << "\t" << "\t" << " | boss編號:" << vip[s].vnum << " | boss姓名:" << vip[s].name << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << " | 服裝編號:" << vip[s].num << " | 服裝名:" << vip[s].bookName << " | 設(shè)計師:" << vip[s].author << " | 品牌:" << vip[s].press << endl;for ( int h = 1; h <= 120; h++)cout<<"-";cout << "\n"; } //按編號查詢 boss int LookupNumVIP() {int j = 0;int num;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 boss編號:";cin >> num;for (int i = 0; i < 100; i++) {if (vip[i].vnum == num) {OutputVIP(i);j = 1;return i;}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 boss" << "\n" << endl;}return 1000; }//按 boss姓名查找 boss void LookupNameVIP() {int j = 0;string name;cout << "\t" << "\t" << "\t" << "\t" << "請輸入 boss姓名:";cin >> name;for (int i = 0; i < 100; i++) {if (vip[i].name == name) {j = 1;OutputVIP(i);break;}}if (j == 0) {cout << "\n" << "\t" << "\t" << "\t" << "\t" << "沒有該 boss" << "\n" << endl;} }//刪除 boss借 服裝信息 void DeleteVIPbook() {int s = LookupNumVIP();vip[s].author = '\0';vip[s].bookName = '\0';vip[s].num = 0;vip[s].press = '\0';}//刪除 boss函數(shù) void Delete() {int s = LookupNumVIP();vip[s].name = '\0';vip[s].vnum = 0;vip[s].author = '\0';vip[s].bookName = '\0';vip[s].num = 0;vip[s].press = '\0';cout << "\n" << "\t" << "\t" << "\t" << "\t" << " boss刪除成功" << endl; }//根據(jù) boss編號查詢借 服裝信息 void Query() {LookupNumVIP(); }//還 服裝函數(shù) void Return() {DeleteVIPbook();cout << "\n" << "\t" << "\t" << "\t" << "\t" << " 服裝歸還成功" << "\n" << endl; }// 服裝借閱函數(shù) void Borrow() {int b = LookupBook();int s = LookupNumVIP();vip[s].bookName = book[b].bookName;vip[s].author = book[b].author;vip[s].num = book[b].num;vip[s].press = book[b].press;cout << "\n" << "\t" << "\t" << "\t" << "\t" << "借 服裝成功" << "\n" << endl; } //保存數(shù)據(jù) void SaveData() {//記錄存入文件函數(shù) // fstream file("衣服.txt", ios::out|ios::binary); // if (!file) { // cout << "file can't open." << endl; // abort(); //立即終止當(dāng)前進程, 產(chǎn)生異常程序終止 // } // for (int i = 0; i < 100; i++) // file.write((char*)(&book[i]), sizeof(book[i])); // file.close(); // ofstream outfile("衣服.dat",ios::out|ios::binary) ;ofstream outfile("衣服.txt",ios::out|ios::binary) ;if(!outfile){cout<<"error...";}for(int i = 0;i < 10;i++ ){// outfile.write((char*)&book[i],sizeof(book[i]) );outfile<<book[i].num<<" " << book[i].bookName << " " << book[i].author << " " << book[i].press <<" "<<book[i].prize<< endl;}outfile.close();// int b = 0; // ofstream fw; // fw.open("C:\\Users\\歡迎來到露兒銀行\(zhòng)\Desktop\\OK\\衣服.txt",ios::in|ios::out); //打開文件 // for (b=0; b < times; b++) // fw << book[b].num<<" " << book[b].bookName << " " << book[b].author // << " " << book[b].press << endl; //讀入一個數(shù)a // fw.close();cout << "ok!!!"; } //打開數(shù)據(jù) void OpenData() { // ofstream infile("衣服.txt",ios::out|ios::binary); // if(!infile) // { // cout<<"error..."; // }// ifstream infile ("衣服.dat",ios::out|ios::binary );ifstream infile ("衣服.txt",ios::out|ios::binary );if (!infile){cout<<"error...";}for(int i = 0;i < 10;i++ ){ // infile.read((char*)&book[i],sizeof(book[i]) );infile>>book[i].num>> book[i].bookName >> book[i].author >> book[i].press >>book[i].prize;}infile.close();cout << "OK!!";system("pause"); // int i=0,x; // ifstream fw; // // fw.open("C:\\Users\\歡迎來到露兒銀行\(zhòng)\Desktop\\OK\\衣服.txt", ios::in | ios::out); // while (fw >> book[i].num >>book[i].bookName >> book[i].author >> book[i].press) { // i++; // } // fw.close();cin >> x;} //首頁 void Index() {int i;for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}system("cls");cout << "\n" << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 服裝管理系統(tǒng) ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、 服裝管理 2、 boss管理 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、系統(tǒng)管理 4、退出 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i) {case 1:BookInterface();break;case 2:VIPInterface();break;case 3:BookSysterm();break;case 4:break;default:cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入1或2" << "\n" << endl;cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");Index();} }// 服裝管理界面 void BookInterface() {for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}system("cls");int i;cout << "\n" << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 服裝管理系統(tǒng) ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、增加 服裝 2、查詢 服裝 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl; // cout << "\t" << "\t" << "\t" << "\t" << "**** 3、 服裝借閱 4、 服裝歸還 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、刪除 服裝 4.返回首頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i) {case 1:add(); //增加 服裝函數(shù)cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");BookInterface();break;case 2:LookupBookIn(); // 服裝查詢頁面break; // case 3: // Output(10) ;// 服裝借閱函數(shù)cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");BookInterface(); // break; // case 4: // Return(); //還 服裝函數(shù) // cout << "\n" << "\t" << "\t" << "\t" << "\t"; // system("pause"); // BookInterface(); // break;case 3:DeleteBook(); //刪除 服裝函數(shù)cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");BookInterface();break;case 4:Index();default:cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入對應(yīng)編號" << "\n" << endl;cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");BookInterface();} }// boss管理界面 void VIPInterface() {for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}system("cls");int i;cout << "\n" << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 服裝管理系統(tǒng) ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、增加 boss 2、查詢 boss ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、boss使用服裝信息 4、刪除 boss ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 5、返回首頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i) {case 1:addVIP(); //增加 boss函數(shù)cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");VIPInterface();break;case 2:LookupVIPIn(); // boss查詢頁面break;case 3:Query(); //根據(jù) boss編號查詢借 服裝信息cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");VIPInterface();break;case 4:Delete(); //刪除 boss函數(shù)cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");VIPInterface();break;case 5:Index();break;default:cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入對應(yīng)編號" << "\n" << endl;cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");VIPInterface();} }// 服裝查詢頁面 void LookupBookIn() { for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}system("cls");int i;cout << "\n" << "\t" << "\t" << "\t" << "-------------------------------------------------------" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**********************- 管- 理- 程 -序***************** "<< endl;cout << "\t" << "\t" << "\t" << "\t" << "**************************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、 服裝編號查詢 2、 服裝名查詢 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、 服裝設(shè)計師查詢 4、 服裝品牌查詢 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 5、返回上一頁 6、返回首頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**************************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i) {case 1:LookupNum(); //通過編號查找cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupBookIn();break;case 2:LookupBook(); //通過 服裝名查找cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupBookIn();break;case 3:LookupAuthor(); //通過設(shè)計師名查找cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupBookIn();break;case 4:LookupPress(); //通過品牌查找cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupBookIn();break;case 5:BookInterface(); // 服裝管理界面break;case 6:Index();break;default:cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入對應(yīng)編號" << "\n" << endl;cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupBookIn();} }// boss查詢頁面 void LookupVIPIn() {for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}int i;system("cls");cout << "\n" << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 服裝管理系統(tǒng) ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、通過編號查找 boss ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 2、通過姓名查找 boss ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、返回上一頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 4、返回首頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i) {case 1:LookupNumVIP(); //按編號查詢 bosscout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupVIPIn();break;case 2:LookupNameVIP(); //按 boss姓名查找 bosscout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupVIPIn();break;case 3:VIPInterface(); // boss管理界面break;case 4:Index();break;default:cout << "\n" << "\t" << "\t" << "\t" << "\t" << "請輸入對應(yīng)編號" << "\n" << endl;cout << "\n" << "\t" << "\t" << "\t" << "\t";system("pause");LookupVIPIn();} } //系統(tǒng)管理頁面 void BookSysterm() {for (int i = 0; i < 10; i++) {Sleep(10);cout << ".";}int i;system("cls");cout << "\n" << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 系統(tǒng)管理 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 1、保存數(shù)據(jù) 2、打開數(shù)據(jù) ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** 3、返回首頁 ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "**** ****" << endl;cout << "\t" << "\t" << "\t" << "\t" << "****************************************" << "\n" << endl;cout << "\t" << "\t" << "\t" << "\t" << "請選擇:";cin >> i;switch (i){case 1:SaveData();BookSysterm() ;break;case 2:OpenData();print( ) ;system("pause");BookSysterm() ;break; case 3:Index();break;} }注意:
文件操作:自己在同一目錄下創(chuàng)建一個.txt文件
寫入文件
?寫出文件
運行效果
總結(jié)
以上是生活随笔為你收集整理的C + + 课程设计之服装信息管理系统。①代码分析(含有源码)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: go下载安装
- 下一篇: Unity3D游戏开发之快速打造流行的关