基於C++說話完成靈活車背章處分治理體系。本站提示廣大學習愛好者:(基於C++說話完成靈活車背章處分治理體系)文章只能為提供參考,不一定能成為您想要的結果。以下是基於C++說話完成靈活車背章處分治理體系正文
症結代碼以下所示:
#include <iostream> #include <iomanip> #include <fstream> #include <string> #include <list> using namespace std; class Violation{ public: Violation(){points=fine=0; number=carNumber=tel=location=isSpot =police=camera=type=isTreated=treatmentDate=notes="";} Violation(string snumber,string sdate="",string scarNumber="",string stel="", string slocation="",int ipoints=-1,string sisSpot="", string spolice="",string scamera="",string itype="",int ifine=0, string sisTreated="",string streatmentDate="",string snotes="") :number(snumber),date(sdate),carNumber(scarNumber),tel(stel), location(slocation),points(ipoints),isSpot(sisSpot),police(spolice), camera(scamera),type(itype),fine(ifine),isTreated(sisTreated), treatmentDate(streatmentDate),notes(snotes){} bool operator==(const Violation& vltn); //查找用 friend bool compNumber(Violation& vltn1,Violation& vltn2); //編號比擬規矩 friend bool compDate(Violation& vltn1,Violation& vltn2); //日期比擬規矩 friend bool compCarNumber(Violation& vltn1,Violation& vltn2); //車商標比擬規矩 friend bool compLocation(Violation& vltn1,Violation& vltn); //所在比擬規矩 friend bool compPoints(Violation& vltn1,Violation& vltn); //扣分比擬規矩 friend istream& operator>>(istream& input,Violation& vltn); friend ostream& operator<<(ostream& output,Violation& vltn); friend class List; friend int saveFile(); private: string number; //編號 string date; //日期 string carNumber; //車商標 string tel; //接洽德律風- string location; //所在 int points; //扣分 string isSpot; //現場 string police; //現場執勤交警 string camera; //非現場攝像頭編號 string type; //背章種別 int fine; //罰款 string isTreated; //能否處置 string treatmentDate; //處置日期 string notes; //備注 }; bool Violation::operator==(const Violation& vltn){ if(location==""||vltn.location=="") if(tel==""||vltn.tel=="") if(carNumber==""||vltn.carNumber=="") if(date==""||vltn.date=="") return number==vltn.number; else return date==vltn.date; else return carNumber==vltn.carNumber; else return tel==vltn.tel; else return location==vltn.location; } bool compNumber(Violation& vltn1,Violation& vltn2){ return vltn1.number>vltn2.number; } bool compDate(Violation& vltn1,Violation& vltn2){ return vltn1.date>vltn2.date; } bool compCarNumber(Violation& vltn1,Violation& vltn2){ return vltn1.carNumber<vltn2.carNumber; } bool compLocation(Violation& vltn1,Violation& vltn2){ return vltn1.location>vltn2.location; } bool compPoints(Violation& vltn1,Violation& vltn2){ return vltn1.points>vltn2.points; } istream& operator>>(istream& input,Violation& vltn){ input>>vltn.number>>vltn.date>>vltn.carNumber>>vltn.tel>>vltn.location >>vltn.points>>vltn.isSpot>>vltn.police>>vltn.camera>>vltn.type >>vltn.fine>>vltn.isTreated>>vltn.treatmentDate>>vltn.notes; return input; } ostream& operator<<(ostream& output,Violation& vltn){ output<<setw(6)<<vltn.number <<setw(9)<<vltn.date <<setw(9)<<vltn.carNumber <<setw(12)<<vltn.tel <<setw(11)<<vltn.location <<setw(5)<<vltn.points <<setw(9)<<vltn.isSpot <<setw(13)<<vltn.police <<setw(17)<<vltn.camera <<setw(11)<<vltn.type <<setw(5)<<vltn.fine <<setw(9)<<vltn.isTreated <<setw(9)<<vltn.treatmentDate <<setw(33)<<vltn.notes<<endl; return output; } class List{ public: friend class User; int loadFile(); //讀取文件 int saveFile(); //保留到文件 int insert(); //添加記載 int change(); //修正記載 int del(); //刪除記載 int browse(); //閱讀記載 int searchMenu(); //查詢信息 int searchCarNumber(); //按車商標 int searchDate(); //按日期查找 int searchTel(); //按德律風查找 int searchLocation(); //按所在查詢 int countMenu(); //統計信息 int countDate(); //按日期統計背章 int countCarNumber(); //按車牌統計背章 int countLocation(); //按所在統計背章 int countPoints(); //按扣分統計背章 static List* getList(); private: list <Violation> vltnlist; static List* m_list; List(){}; List(const List&){} List& operator=(const List&){} }; const char* filepath="violation.dat"; //指定命據文件途徑 bool checkNumber(string s,int size){ if(s.size()!=size) return false; for(int i=0;i<size;i++) if(s[i]<'0'||s[i]>'9') return false; return true; } List* List::m_list=NULL; List* List::getList(){ if(NULL==m_list) m_list=new List; return m_list; } int List::loadFile(){ ifstream infile(filepath,ios::in); if(infile) for(;!infile.eof();){ Violation vltn;infile>>vltn; vltnlist.push_back(vltn); } infile.close(); return 0; } int List::saveFile(){ ofstream outfile(filepath,ios::out); list<Violation>::iterator it; for(it=vltnlist.begin();it!=vltnlist.end();it++) outfile<<endl<<it->number<<' '<<it->date<<' '<<it->carNumber<<' ' <<it->tel<<' '<<it->location<<' '<<it->points<<' '<<it->isSpot<<' ' <<it->police<<' '<<it->camera<<' '<<it->type<<' '<<it->fine<<' ' <<it->isTreated<<' '<<it->treatmentDate<<' '<<it->notes; outfile.close(); return 0; } int List::insert(){ list<Violation>::iterator it; string number,date,carNumber,tel,location,isSpot,police,camera,type, isTreated,treatmentDate,notes; int points,fine; cout<<"請輸出背章編號【廢棄添加 0】【5位數字,如16384】:"; for(;;){ cin>>number;cin.sync(); if(number=="0") return 0; if(!checkNumber(number,5)) { cout<<"請輸出有用編號:"; continue; } Violation l(number); it=find(vltnlist.begin(),vltnlist.end(),l); if(it!=vltnlist.end()) cout<<"編號已存在,請從新輸出:"; else break; } cout<<"請輸出背章日期【8位數字,如20160630】:"; while(1){ cin>>date;cin.sync(); if(!checkNumber(date,8)){ cout<<"請輸出有用日期:"; continue; } else break; } cout<<"請輸出背章車輛車商標:";cin>>carNumber;cin.sync(); cout<<"請輸出掛號接洽德律風【11位數字,如13751516464】:"; while(1){ cin>>tel;cin.sync(); if(!checkNumber(tel,11)){ cout<<"請輸出有用德律風:"; continue; } else break; } cout<<"請輸出背章所在:";cin>>location;cin.sync(); cout<<"請輸出處分扣分【0~12分】:"; while(1){ if(cin>>points){ cin.sync(); if(points<0||points>12){ cout<<"請輸出有用扣分:"; continue; } else break; } else{ cin.clear();cin.sync(); cout<<"請輸出有用扣分:"; continue; } } cout<<"請輸出能否現場【是 1】:";cin>>isSpot;cin.sync(); if(isSpot=="1"){ cout<<"請輸出現場執勤交警:";cin>>police;cin.sync(); isSpot="是";camera="現場"; } else{ cout<<"請輸出非現場攝像頭編號【6位數字,如646464】:"; while(1){ cin>>camera;cin.sync(); if(!checkNumber(camera,6)){ cout<<"請輸出有用編號:"; continue; } else break; } isSpot="否";police="非現場"; } cout<<"*******************************************************"<<endl; cout<<"* ┌------------背章種別-------------請輸出---------┐*"<<endl; cout<<"* | | *"<<endl; cout<<"* | ◆ 超速 1 | *"<<endl; cout<<"* | ◆ 酒駕 2 | *"<<endl; cout<<"* | ◆ 闖紅燈 3 | *"<<endl; cout<<"* | ◆ 背規變道 4 | *"<<endl; cout<<"* | ◆ 未系平安帶 5 | *"<<endl; cout<<"* | ◆ 超載 6 | *"<<endl; cout<<"* | | *"<<endl; cout<<"* └------------------------------------------------┘*"<<endl; cout<<"*******************************************************"<<endl; cout<<"請選擇背章種別:"; int Mark=1; while(Mark){ char n;cin>>n;cin.sync(); switch(n){ case '1': type="超速";Mark=0;break; case '2': type="酒駕";Mark=0;break; case '3': type="闖紅燈";Mark=0;break; case '4': type="背規變道";Mark=0;break; case '5': type="未系平安帶";Mark=0;break; case '6': type="超載";Mark=0;break; default : cout<<"輸出有誤,請從新輸出:"; } } cout<<"請輸出罰款金額【0~5000元】:"; while(1){ if(cin>>fine){ cin.sync(); if(fine<0||fine>50000){ cout<<"請輸出有用金額:"; continue; } else break; } else{ cin.clear();cin.sync(); cout<<"請輸出有用金額:"; continue; } } cout<<"請輸出能否處置【是 1】:";cin>>isTreated;cin.sync(); if(isTreated=="1"){ cout<<"請輸出處置日期【8位數字,如20160630】:";//cin>>treatmentDate;cin.sync(); while(1){ cin>>treatmentDate;cin.sync(); if(!checkNumber(treatmentDate,8)){ cout<<"請輸出有用日期:"; continue; } else break; } isTreated="是"; } else{ isTreated="否";treatmentDate="未處置"; } cout<<"請輸出備注【無 0】:";cin>>notes;cin.sync(); if(notes=="0") notes="無"; Violation vltn(number,date,carNumber,tel,location,points,isSpot,police,camera, type,fine,isTreated,treatmentDate,notes); vltnlist.push_back(vltn); saveFile(); cout<<"車輛背章信息添加勝利!";getchar(); return 0; } int List::change(){ list<Violation>::iterator it; if(!vltnlist.size()){ cout<<"還沒有記載,不克不及修正!"<<endl;getchar(); return 0; } string number,date,carNumber,tel,location,isSpot,police,camera,type, isTreated,treatmentDate,notes; int points,fine; browse(); cout<<"請輸出想要修正的記載編號【廢棄0】:"; cin>>number;cin.sync(); if(number=="0") return 0; Violation vltn(number); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it==vltnlist.end()){ cout<<"此編號不存在!";getchar(); return 0; } while(1){ system("cls"); cout<<" 以後信息 請輸出"<<endl; cout<<" 背章編號:"<<setw(17)<<(*it).number<<" 1"<<endl <<" 背章日期:"<<setw(17)<<(*it).date<<" 2"<<endl <<" 車輛車商標:"<<setw(17)<<(*it).carNumber<<" 3"<<endl <<" 掛號接洽德律風:"<<setw(17)<<(*it).tel<<" 4"<<endl <<" 背章所在:"<<setw(17)<<(*it).location<<" 5"<<endl <<" 處分扣分:"<<setw(17)<<(*it).points<<" 6"<<endl <<" 能否現場:"<<setw(17)<<(*it).isSpot<<endl <<" 現場執勤交警:"<<setw(17)<<(*it).police<<" 7"<<endl <<" 非現場攝像頭編號:"<<setw(17)<<(*it).camera<<" 8"<<endl <<" 背章種別:"<<setw(17)<<(*it).type<<" 9"<<endl <<" 罰款金額:"<<setw(17)<<(*it).fine<<" a"<<endl <<" 能否處置:"<<setw(17)<<(*it).isTreated<<" b"<<endl <<" 處置日期:"<<setw(17)<<(*it).treatmentDate<<" c"<<endl <<" 備注:"<<endl<<setw(34)<<(*it).notes<<" d"<<endl; cout<<"請選摘要修正的條目【廢棄修正 0】:"; int Mark=1; while(Mark){ char n;cin>>n;cin.sync(); switch(n){ case '0': return 0; case '1': cout<<"請輸出背章編號【5位數字,如16384】:";//cin>>(*it).number;cin.sync(); for(;;){ cin>>number;cin.sync(); if(!checkNumber(number,5)) { cout<<"請輸出有用編號:"; continue; } Violation l(number); list<Violation>::iterator nit; nit=find(vltnlist.begin(),vltnlist.end(),l); if(nit!=vltnlist.end()) cout<<"編號已存在,請從新輸出:"; else { (*it).number=number;break; } } Mark=0;break; case '2': cout<<"請輸出背章日期【8位數字,如20160630】:";//cin>>(*it).date;cin.sync(); while(1){ cin>>date;cin.sync(); if(!checkNumber(date,8)){ cout<<"請輸出有用日期:"; continue; } else { (*it).date=date;break; } } Mark=0;break; case '3': cout<<"請輸出車輛車商標:";cin>>(*it).carNumber;cin.sync(); Mark=0;break; case '4': cout<<"請輸出掛號接洽德律風:";//cin>>(*it).tel;cin.sync(); while(1){ cin>>tel;cin.sync(); if(!checkNumber(tel,11)){ cout<<"請輸出有用德律風【11位數字,如13751516464】:"; continue; } else { (*it).tel=tel;break; } } Mark=0;break; case '5': cout<<"請輸出背章所在:";cin>>(*it).location;cin.sync(); Mark=0;break; case '6': cout<<"請輸出處分扣分【0~12分】:";//cin>>(*it).points;cin.sync(); while(1){ if(cin>>points){ cin.sync(); if(points<0||points>12){ cout<<"請輸出有用扣分:"; continue; } else{ (*it).points=points;break; } } else{ cin.clear();cin.sync(); cout<<"請輸出有用扣分:"; continue; } } Mark=0;break; case '7': cout<<"請輸出現場執勤交警:";cin>>(*it).police;cin.sync(); (*it).isSpot="是";(*it).camera="現場"; Mark=0;break; case '8': cout<<"請輸出非現場攝像頭編號【6位數字,如646464】:";//cin>>(*it).camera;cin.sync(); while(1){ cin>>camera;cin.sync(); if(!checkNumber(camera,6)){ cout<<"請輸出有用編號:"; continue; } else{ (*it).camera=camera;break; } } (*it).isSpot="否";(*it).police="非現場"; Mark=0;break; case '9': { cout<<"*******************************************************"<<endl; cout<<"* ┌------------背章種別-------------請輸出---------┐*"<<endl; cout<<"* | | *"<<endl; cout<<"* | ◆ 超速 1 | *"<<endl; cout<<"* | ◆ 酒駕 2 | *"<<endl; cout<<"* | ◆ 闖紅燈 3 | *"<<endl; cout<<"* | ◆ 背規變道 4 | *"<<endl; cout<<"* | ◆ 未系平安帶 5 | *"<<endl; cout<<"* | ◆ 超載 6 | *"<<endl; cout<<"* | | *"<<endl; cout<<"* └------------------------------------------------┘*"<<endl; cout<<"*******************************************************"<<endl; cout<<"請選擇背章種別:"; int Mark1=1; while(Mark1){ char n1;cin>>n1;cin.sync(); switch(n1){ case '1': (*it).type="超速";Mark1=0;break; case '2': (*it).type="酒駕";Mark1=0;break; case '3': (*it).type="闖紅燈";Mark1=0;break; case '4': (*it).type="背規變道";Mark1=0;break; case '5': (*it).type="未系平安帶";Mark1=0;break; case '6': (*it).type="超載";Mark1=0;break; default : cout<<"輸出有誤,請從新輸出:"; } } Mark=0;break; } case 'a': cout<<"請輸出罰款金額【0~5000元】:";//cin>>(*it).fine;cin.sync(); while(1){ if(cin>>fine){ cin.sync(); if(fine<0||fine>50000){ cout<<"請輸出有用金額:"; continue; } else{ (*it).fine=fine;break; } } else{ cin.clear();cin.sync(); cout<<"請輸出有用金額:"; continue; } } Mark=0;break; case 'b': cout<<"請輸出能否處置【是 1】:";cin>>(*it).isTreated;cin.sync(); if((*it).isTreated=="1"){ cout<<"輸出處置日期:";//cin>>(*it).treatmentDate;cin.sync(); while(1){ cin>>treatmentDate;cin.sync(); if(!checkNumber(treatmentDate,8)){ cout<<"請輸出有用日期:"; continue; } else { (*it).treatmentDate=treatmentDate;break; } } (*it).isTreated="是"; } else{ (*it).isTreated="否";(*it).treatmentDate="未處置"; } Mark=0;break; case 'c': cout<<"請輸出處置日期【8位數字,如20160630】:";//cin>>(*it).treatmentDate;cin.sync(); while(1){ cin>>treatmentDate;cin.sync(); if(!checkNumber(treatmentDate,8)){ cout<<"請輸出有用日期:"; continue; } else{ (*it).treatmentDate=treatmentDate;break; } } Mark=0;break; case 'd': cout<<"請輸出備注:";cin>>(*it).notes;cin.sync(); Mark=0;break; default : cout<<"輸出有誤,請從新輸出:"; } } saveFile(); cout<<"修正勝利!"<<endl <<"持續修正請輸出隨意率性鍵,修正終了請輸出0:"; char ch;cin>>ch;cin.sync(); if(ch=='0') return 0; } } int List::del(){ list<Violation>::iterator it; if(!vltnlist.size()){ cout<<"還沒有記載,不克不及刪除!"<<endl;getchar(); return 0; } string number; browse(); cout<<"請輸出想要刪除的編號【廢棄0】:"; cin>>number;cin.sync(); if(number=="0") return 0; Violation vltn(number); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it==vltnlist.end()){ cout<<"此編號不存在!";getchar(); return 0; } vltnlist.erase(it); if(!vltnlist.size()) remove(filepath); else saveFile(); cout<<"刪除記載勝利!";getchar(); return 0; } int List::browse(){ list<Violation>::iterator it; if(!vltnlist.size()){ cout<<"還沒有記載!"<<endl;getchar(); return 0; } vltnlist.sort(compNumber); //按編號降序分列 cout<<"以後共有 "<<vltnlist.size()<<"筆記錄,已按編號降序分列:"<<endl <<" 編號 日期 車商標 接洽德律風 所在 扣分 能否現場 現場執勤交警 非現場攝像頭編號 背章種別 罰款 能否處置 處置日期 備注"<<endl; for(it=vltnlist.begin();it!=vltnlist.end();it++) cout<<*it; getchar(); return 0; } int List::searchMenu(){ if(!vltnlist.size()){ cout<<"還沒有記載,不克不及查詢!"<<endl;getchar(); return 0; } while(1) { system("cls"); cout<<"*******************************************************"<<endl; cout<<"* ★靈活車背章處分治理體系 ★ *"<<endl; 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; cout<<"*******************************************************"<<endl; cout<<"* ● 前往主菜單 0 *"<<endl; cout<<"*******************************************************"<<endl; cout<<"請選擇查詢方法:"; int Mark=1; while(Mark){ char n;cin>>n;cin.sync(); switch(n) { case '1': searchDate();Mark=0;break; case '2': searchCarNumber();Mark=0;break; case '3': searchTel();Mark=0;break; case '4': searchLocation();Mark=0;break; case '0': return 0; default : cout<<"輸出有誤,請從新輸出:"; } } } vltnlist.sort(compNumber); return 0; getchar();return 0; } int List::searchDate(){ list<Violation>::iterator it; string date; cout<<"請輸出日期:";cin>>date;cin.sync(); Violation vltn("",date); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it!=vltnlist.end()){ cout<<"已找到日期為 "<<date<<" 的背章記載:"<<endl <<" 編號 日期 車商標 接洽德律風 所在 扣分 能否現場 現場執勤交警 非現場攝像頭編號 背章種別 罰款 能否處置 處置日期 備注"<<endl <<*it; for(it++;it!=vltnlist.end();it++) if(*it==vltn) cout<<*it; } else cout<<"沒有該日期的背章記載!"; getchar();return 0; } int List::searchCarNumber(){ list<Violation>::iterator it; string carNumber; cout<<"請輸出車商標:";cin>>carNumber;cin.sync(); Violation vltn("","",carNumber); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it!=vltnlist.end()){ cout<<"已找到車商標為 "<<carNumber<<" 的背章記載:"<<endl <<" 編號 日期 車商標 接洽德律風 所在 扣分 能否現場 現場執勤交警 非現場攝像頭編號 背章種別 罰款 能否處置 處置日期 備注"<<endl <<*it; for(it++;it!=vltnlist.end();it++) if(*it==vltn) cout<<*it; } else cout<<"沒有該車商標的背章記載!"; getchar();return 0; } int List::searchTel(){ list<Violation>::iterator it; string tel; cout<<"請輸出接洽德律風:";cin>>tel;cin.sync(); Violation vltn("","","",tel); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it!=vltnlist.end()){ cout<<"已找到接洽德律風為 "<<tel<<" 的背章記載:"<<endl <<" 編號 日期 車商標 接洽德律風 所在 扣分 能否現場 現場執勤交警 非現場攝像頭編號 背章種別 罰款 能否處置 處置日期 備注"<<endl <<*it; for(it++;it!=vltnlist.end();it++) if(*it==vltn) cout<<*it; } else cout<<"沒有該接洽德律風的背章記載!"; getchar();return 0; } int List::searchLocation(){ list<Violation>::iterator it; string location; cout<<"請輸出所在:";cin>>location;cin.sync(); Violation vltn("","","","",location); it=find(vltnlist.begin(),vltnlist.end(),vltn); if(it!=vltnlist.end()){ cout<<"已找到所在為 "<<location<<" 的背章記載:"<<endl <<" 編號 日期 車商標 接洽德律風 所在 扣分 能否現場 現場執勤交警 非現場攝像頭編號 背章種別 罰款 能否處置 處置日期 備注"<<endl <<*it; for(it++;it!=vltnlist.end();it++) if(*it==vltn) cout<<*it; } else cout<<"沒有該所在的背章記載!"; getchar();return 0; } int List::countMenu(){ list<Violation>::iterator it; if(!vltnlist.size()){ cout<<"還沒有記載,不克不及統計!"<<endl;getchar(); return 0; } while(1) { system("cls"); cout<<"*******************************************************"<<endl; cout<<"* *"<<endl; cout<<"* ★靈活車背章處分治理體系 ★ *"<<endl; cout<<"* *"<<endl; cout<<"*******************************************************"<<endl; cout<<"* ┌--------------------統計菜單--------------------┐*"<<endl; cout<<"* | | *"<<endl; cout<<"* | 統計方法 請輸出 | *"<<endl; cout<<"* | ◆ 按日期統計背章數目 1 | *"<<endl; cout<<"* | ◆ 按車商標統計背章次數 2 | *"<<endl; cout<<"* | ◆ 按所在統計背章數目 3 | *"<<endl; cout<<"* | ◆ 顯示處分>=12分的記載 4 | *"<<endl; cout<<"* | | *"<<endl; cout<<"* └------------------------------------------------┘*"<<endl; cout<<"*******************************************************"<<endl; cout<<"* ● 前往主菜單 0 *"<<endl; cout<<"*******************************************************"<<endl; cout<<"請選擇統計方法:"; int Mark=1; while(Mark){ char n;cin>>n;cin.sync(); switch(n) { case '1': countDate();Mark=0;break; case '2': countCarNumber();Mark=0;break; case '3': countLocation();Mark=0;break; case '4': countPoints();Mark=0;break; case '0': return 0; default : cout<<"輸出有誤,請從新輸出:"; } } } return 0; getchar();return 0; } int List::countDate(){ list<Violation>::iterator it; vltnlist.sort(compDate); int sumVltn=0;string y,m1,m2,date1,date2; cout<<"輸出日期規模:"<<endl ; cout<<"輸出年份:";cin>>y;cin.sync(); cout<<"輸出肇端月份:";cin>>m1;cin.sync(); cout<<"輸出停止月份:";cin>>m2;cin.sync(); date1=y+m1;date2=y+m2; for(it=vltnlist.begin();it!=vltnlist.end();it++){ if((*it).date>=date1&&(*it).date<=date2) sumVltn++; } cout<<"該段時光內背章數目為:"<<sumVltn;//getchar(); //vltnlist.push_back(Violation("cutme")); //it=vltnlist.begin(); /* cout<<"已按月份統計背章數目:"<<endl <<" 背章日期 背章數目"<<endl; int sumVltn=0;string mouth=((*it).date).substr(4,2),date=(*it).date.substr(0,4); for(it=vltnlist.begin();it!=vltnlist.end();it++) if((*it).date!=""){ if(mouth!=((*it).date).substr(4,2)){ cout<<(*it).date.substr(0,4)<<"年"<<mouth<<"月"<<setw(9)<<sumVltn<<endl; sumVltn=1;mouth=(*it).date.substr(4,2);date=(*it).date.substr(0,4); } else { sumVltn++; } } else{ cout<<date<<"年"<<mouth<<"月"<<setw(9)<<sumVltn<<endl; }*/ //vltnlist.pop_back(); getchar();return 0; } int List::countCarNumber(){ list<Violation>::iterator it; vltnlist.sort(compCarNumber); vltnlist.push_back(Violation("cutme")); it=vltnlist.begin(); cout<<"已按車商標統計背章次數:"<<endl <<" 車商標 背章次數"<<endl; string carNumber=(*it).carNumber;int sumVltn=0; for(it=vltnlist.begin();it!=vltnlist.end();it++) if(carNumber!=(*it).carNumber){ cout<<setw(9)<<carNumber<<setw(9)<<sumVltn<<endl; carNumber=(*it).carNumber;sumVltn=1; } else sumVltn++; vltnlist.pop_back(); getchar();return 0; } int List::countLocation(){ list<Violation>::iterator it; vltnlist.sort(compLocation); vltnlist.push_back(Violation("cutme")); it=vltnlist.begin(); string location=(*it).location;int sumVltn=0; cout<<"已按所在統計背章數目:"<<endl <<" 所在 背章數目"<<endl; for(it=vltnlist.begin();it!=vltnlist.end();it++) if(location !=(*it).location){ cout<<setw(11)<<location<<setw(9)<<sumVltn<<endl; location=(*it).location;sumVltn=1; } else sumVltn++; vltnlist.pop_back(); getchar();return 0; } int List::countPoints(){ list<Violation>::iterator it; vltnlist.sort(compCarNumber); vltnlist.push_back(Violation("cutme")); it=vltnlist.begin(); string carNumber=(*it).carNumber,tel=(*it).tel; int sumPoints=0; cout<<"已顯示處分>=12分的背章記載:"<<endl <<" 車商標 接洽德律風"<<endl; for(it=vltnlist.begin();it!=vltnlist.end();it++) if(carNumber!=(*it).carNumber){ if(sumPoints>11) cout<<setw(9)<<carNumber<<setw(12)<<tel<<endl; carNumber=(*it).carNumber;sumPoints=(*it).points;tel=(*it).tel; } else sumPoints+=(*it).points; vltnlist.pop_back(); getchar();return 0; } int menu(); int main(){ List* myList=List::getList(); myList->loadFile(); menu(); myList->saveFile(); return 0; } int menu(){ while(1) { system("cls"); cout<<"*******************************************************"<<endl; cout<<"* *"<<endl; cout<<"* ★靈活車背章處分治理體系 ★ *"<<endl; cout<<"* *"<<endl; cout<<"*******************************************************"<<endl; cout<<"* ┌---------------------主菜單---------------------┐*"<<endl; cout<<"* | | *"<<endl; cout<<"* | 功效 請輸出 | *"<<endl; cout<<"* | ◆ 添加背章記載 1 | *"<<endl; cout<<"* | ◆ 修正背章記載 2 | *"<<endl; cout<<"* | ◆ 刪除背章記載 3 | *"<<endl; cout<<"* | ◆ 閱讀背章記載 4 | *"<<endl; cout<<"* | ◆ 查詢背章記載 5 | *"<<endl; cout<<"* | ◆ 統計背章記載 6 | *"<<endl; cout<<"* | | *"<<endl; cout<<"* └------------------------------------------------┘*"<<endl; cout<<"*******************************************************"<<endl; cout<<"* ● 加入治理體系 0 *"<<endl; cout<<"*******************************************************"<<endl; cout<<"請選擇功效:"; int Mark=1; while(Mark){ char n;cin>>n;cin.sync(); List* myList=List::getList(); switch(n) { case '1': myList->insert();Mark=0;break; case '2': myList->change();Mark=0;break; case '3': myList->del();Mark=0;break; case '4': myList->browse();Mark=0;break; case '5': myList->searchMenu();Mark=0;break; case '6': myList->countMenu();Mark=0;break; case '0': exit(0); default : cout<<"輸出有誤,請從新輸出:"; } } } return 0; }
以上代碼是基於C++說話完成靈活車背章處分治理體系的症結代碼,代碼附有正文,有不明確的處所迎接給我留言,小編會實時答復年夜家的,年夜家可以加倍需求恰當的添加修正刪除。