rt 写了个查询代码:
#include<bits/stdc++.h>
using namespace std ;
class node {
private :
string constructionunits ;//建设单位
string projectname ;//项目名称
string projectnumber ;//项目编号
string constructionsite ;//建设地点
string projecttype ;//项目类型
string designcontent ;//设计内容
int contractamount ;//合同额
string designstage ;//设计阶段
string contactinformation ;//联系方式
public :
const string& getconstructionunits() const {
return constructionunits;
}
const string& getprojectname() const {
return projectname;
}
const string& getprojectnumber() const {
return projectnumber;
}
const string& getconstructionsite() const {
return constructionsite;
}
const string& getprojecttype() const {
return projecttype;
}
const string& getdesigncontent() const {
return designcontent;
}
const int& getcontractamount() const {
return contractamount;
}
const string& getdesignstage() const {
return designstage;
}
const string& getcontactinformation() const {
return contactinformation;
}
void setconstructionunits(const string& str) {
constructionunits = str;
}
void setprojectname(const string& str) {
projectname = str;
}
void setprojectnumber(const string& str) {
projectnumber = str;
}
void setconstructionsite(const string& str) {
constructionsite = str;
}
void setprojecttype(const string& str) {
projecttype = str;
}
void setdesigncontent(const string& str) {
designcontent = str;
}
void setcontractamount(int amount) {
contractamount = amount;
}
void setdesignstage(const string& str) {
designstage = str;
}
void setcontactinformation(const string& str) {
contactinformation = str;
}
void print() {
cout << "建设单位:" << constructionunits << ' ' ;//建设单位
cout << "项目名称:" << projectname << ' ' ;//项目名称
cout << "项目编号:" << projectnumber << ' ' ;//项目编号
cout << "建设地点:" << constructionsite << ' ' ;//建设地点
cout << "项目类型:" << projecttype << ' ' ;//项目类型
cout << "设计内容:" << designcontent << ' ' ;//设计内容
cout << "合同额:" << contractamount << ' ' ;//合同额
cout << "设计阶段:" << designstage << ' ' ;//设计阶段
cout << "联系方式:" << contactinformation << ' ' ;//联系方式
}
};
vector<node> v ;
int main() {
// freopen( "存储.txt" , "r" , stdin ) ;
string constructionunits ;//建设单位
string projectname ;//项目名称
string projectnumber ;//项目编号
string constructionsite ;//建设地点
string projecttype ;//项目类型
string designcontent ;//设计内容
int contractamount ;//合同额
string designstage ;//设计阶段
string contactinformation ;//联系方式
string str ;
cin >> str ;
while ( str != "End" && str != "end" ) {
constructionunits = str ;//建设单位
cin >> projectname ;//项目名称
cin >> projectnumber ;//项目编号
cin >> constructionsite ;//建设地点
cin >> projecttype ;//项目类型
cin >> designcontent ;//设计内容
cin >> contractamount ;//合同额
cin >> designstage ;//设计阶段
cin >> contactinformation ;//联系方式
node x ;
x.setconstructionunits(constructionunits) ;
x.setprojectname(projectname) ;
x.setprojectnumber(projectnumber) ;
x.setconstructionsite(constructionsite) ;
x.setprojecttype(projecttype) ;
x.setdesigncontent(designcontent) ;
x.setcontractamount(contractamount) ;
x.setdesignstage(designstage) ;
x.setcontactinformation(contactinformation) ;
v.push_back(x) ;
}
// fclose(stdin) ;
// cin.clear() ;
// freopen( "输入.txt" , "r" , stdin ) ;
// freopen( "输出.txt" , "w" , stdout ) ;
int n ;
cin >> n ;
while ( n-- ) {
string op ;
cin >> op ;
if ( op == "建设地点" || op == "地点" || op == "项目地点" ) {
string str ;
cin >> str ;
for ( int i = 0 ; i < v.size() ; i++ ) {
if ( v[i].getconstructionsite() == str ) {
v[i].print() ;
}
}
}
}
// fclose(stdin) ;
// fclose(stdout) ;
return 0 ;
}