首页 > > 详细

讲解C/C++ Data数据结构编程、C/C++设计讲解、辅导留学生C/C++语言程序

#include
#include
#include
using namespace std;
#include
#include
struct goods
{
char date[15];
char course[20];
char time[10];
char id[20];
char name[20];
char sex[10];
char banji[20];
int type;
};
const char*file="goods.dat";
class Data
{
public:
Data(){}
Data(string Date,string Course,string Time,string Id,string Name,string Sex,string Banji,int Type):
date(Date),course(Course),time(Time),id(Id),name(Name),sex(Sex),banji(Banji),type(Type){}
void setdate(stringsdate)
{
date=sdate;
}
void setcourse(stringscourse)
{
course=scourse;
}
void settime(stringstime)
{
time=stime;
}
void setid(stringsid)
{
id=sid;
}
void setname(stringsname)
{
name=sname;
}
void setsex(stringssex)
{
sex=ssex;
}
void setbanji(stringsbanji)
{
banji=sbanji;
}
void settype(intssype)
{
type=ssype;
}
string getdate()
{
return date;
}
string getcourse()
{
return course;
}
string gettime()
{
return time;
}
string getname()
{
return name;
}
string getsex()
{
return sex;
}
string getbanji()
{
return banji;
}
int gettype()
{
return type;
}
string getid()
{
return id;
}
void Print();
private:
string date;
string course;
string time;
string id;
string name;
string sex;
string banji;
int type;

};
void Data::Print()
{
coutGetNext();
n++;
cout=count)
{
return NULL;
}
for(int i=0;iGetNext();
}
return pn->GetData();
}
Data*List::GetFirst()
{
if (head)
{
return head->GetData();
}
else
{
return NULL;
}
}
List::Find(string number)
{
Node*pn=0;
int a=0;
for(pn=head;pn!=NULL;pn=pn->GetNext())
{
if(pn->GetData()->getid()==number)
{
pn->GetData()->Print();
a=1;
}

}
if(a==0)
{
coutGetNext())
{
if(pn->GetData()->getname()==Name)
{
pn->GetData()->Print();
pn1=pn;
a++;
}

}
if (a==1)
{
while(1)
{
if (!choice)
{
pn1->GetData()->Print();
break;
}

qwe: cout>choice;
switch(choice)
{
case 1:
cout>date;
pn1->GetData()->setdate(date);
break;
case 2:
cout>course;
pn1->GetData()->setcourse(course);
break;
case 3:
cout>time;
pn1->GetData()->settime(time);
break;
case 4:
cout>id;
pn1->GetData()->setid(id);
break;
case 5:
cout>name;
pn1->GetData()->setname(name);
break;
case 6:
cout>type;
pn1->GetData()->settype(type);
break;
default:
cout>choice;
}

}
if (a!=1)
{
cout>date;
for(pn=head;pn!=NULL;pn=pn->GetNext())
{
if(pn->GetData()->getname()==Name pn->GetData()->getdate()==date)
{
pn->GetData()->Print();
pn1=pn;
b=true;
}
}
if (b)
{

while(1)
{
if (!choice)
{
pn1->GetData()->Print();
break;
}

qwe1: cout>choice;
switch(choice)
{
case 1:
cout>date;
pn1->GetData()->setdate(date);
break;
case 2:
cout>course;
pn1->GetData()->setcourse(course);
break;
case 3:
cout>time;
pn1->GetData()->settime(time);
break;
case 4:
cout>id;
pn1->GetData()->setid(id);
break;
case 5:
cout>name;
pn1->GetData()->setname(name);
break;
case 6:
cout>type;
pn1->GetData()->settype(type);
break;
default:
cout>choice;
}
}
else
{
coutGetNext())
{
if(pn->GetData()->getid()==number)
{
pn->GetData()->Print();
pn1=pn;
a++;
}

}
if (a==1)
{
while(1)
{
if (!choice)
{
pn1->GetData()->Print();
break;
}

qwe: cout>choice;
switch(choice)
{
case 1:
cout>date;
pn1->GetData()->setdate(date);
break;
case 2:
cout>course;
pn1->GetData()->setcourse(course);
break;
case 3:
cout>time;
pn1->GetData()->settime(time);
break;
case 4:
cout>id;
pn1->GetData()->setid(id);
break;
case 5:
cout>name;
pn1->GetData()->setname(name);
break;
case 6:
cout>type;
pn1->GetData()->settype(type);
break;
default:
cout>choice;
}

}
if (a!=1)
{
cout>date;
for(pn=head;pn!=NULL;pn=pn->GetNext())
{
if(pn->GetData()->getid()==number pn->GetData()->getdate()==date)
{
pn->GetData()->Print();
pn1=pn;
b=true;
}
}
if (b)
{

while(1)
{
if (!choice)
{
pn1->GetData()->Print();
break;
}

qwe1: cout>choice;
switch(choice)
{
case 1:
cout>date;
pn1->GetData()->setdate(date);
break;
case 2:
cout>course;
pn1->GetData()->setcourse(course);
break;
case 3:
cout>time;
pn1->GetData()->settime(time);
break;
case 4:
cout>id;
pn1->GetData()->setid(id);
break;
case 5:
cout>name;
pn1->GetData()->setname(name);
break;
case 6:
cout>type;
pn1->GetData()->settype(type);
break;
default:
cout>choice;
}
}
else
{
coutGetNext())
{
if(pn->GetData()->getname()==Name)
{
pn->GetData()->Print();
a=1;
}
}
if(a==0)
coutGetNext())
{
if(pn->GetData()->getcourse()==Course)
{
pn->GetData()->Print();
a=1;
}
}
if (a==0)
{
coutGetNext())
{
if(pn->GetData()->getname()==Name)
{
if(pn->GetData()->gettype()==1 || pn->GetData()->gettype()==2)
{
sum+=1;
}
else if(pn->GetData()->gettype()==3)
{
sum+=2;
}
else
{
sum=sum;
}
a=1;
}
}
coutGetData()->Print();
}while(pn=pn->GetNext());
}
void List::Insert(Data*pData)
{
Node*pn=new Node(pData);
Node*pNow=head;
Node*pNext=0;
string New=pData->getdate();
string next;
count++;
if(!head)
{
head=pn;
return;
}
if(head->GetData()->getdate()>New)
{
pn->SetNext(head);
head=pn;
return;
}
for(;;)
{
if(!pNow->GetNext())
{
pNow->SetNext(pn);
return;
}
pNext=pNow->GetNext();
next=pNext->GetData()->getdate();
if(next>New)
{
pNow->SetNext(pn);
pn->SetNext(pNext);
return;
}
pNow=pNext;
}
}
int main()
{
List pl;
Data*pdata=0;
int choice;
bool quit=false;
string date;
string course;
string time;
string id;
string name;
string sex;
string banji;
int type;
while (1)
{
system("cls");
cout>choice;
switch (choice)
{
case 1:
system("cls");
while (1)
{

if (!choice)
{
break;
}
else if (choice==1)
{
cout>date;
cout>course;
cout>time;
cout>id;
cout>name;
cout>sex;
cout>banji;
cout>type;
pdata=new Data(date,course,time,id,name,sex,banji,type);
pl.Insert(pdata);


}
else
cout>choice;
}
break;
case 2:
system("cls");
if(pl.GetFirst()==0)
{
cout>choice;
if(!choice)
{
break;
}
if(choice==1)
{
cout>id;
pl.Find(id);

}
else if(choice==2)
{
cout>name;
pl.Find2(name);

}
else
cout>choice;
if(!choice)
{
break;
}
if(choice==1)
{
cout>id;
pl.Find3(id);
}
else if(choice==2)
{
cout>name;
pl.Find4(name);
}

else
cout>name;
pl.Find11(name);
cout>num;
if (num==0)
{
coutdate,p->getdate().c_str());
strcpy(pp->course,p->getcourse().c_str());
strcpy(pp->time,p->gettime().c_str());
strcpy(pp->id,p->getid().c_str());
strcpy(pp->name,p->getname().c_str());
strcpy(pp->sex,p->getsex().c_str());
strcpy(pp->banji,p->getbanji().c_str());
pp->type=p->gettype();
coutdatecoursetimeidnamesexbanjitype::max(), '\n' );
cout<<"1-6,"< cin.get();
break;
}
if (quit)
{
cout<<"\n";
break;
}
}
return 0;
}
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!