📄 mainframe1.cpp
字号:
poskk.Y++;
kk[3].createbutton(poskk,"中专",14,10,hOut);
poskk.Y++;
kk[4].createbutton(poskk,"大专",14,10,hOut);
poskk.Y++;
kk[5].createbutton(poskk,"本科",14,10,hOut);
poskk.Y++;
kk[6].createbutton(poskk,"硕士",14,10,hOut);
poskk.Y++;
kk[7].createbutton(poskk,"博士",14,10,hOut);
poskk.Y++;
kk[8].createbutton(poskk,"其他",14,10,hOut);
for(;;)
{
BOOL tal=false;
ReadConsoleInput(hIn, &mouseRec, 1,&res);
for(int j=0;j<9;j++)
{
mousemove1(hOut,hIn,kk[j],mouseRec);
}
for(int jj=0;jj<9;jj++)
{
if(mouseclickl(hOut,hIn,kk[jj],mouseRec))
{
clearscreen(hOut,pos,posa);
SetConsoleCursorPosition(hOut,pos);
strcpy(p->a.xueli,kk[jj].buttonname);
cout<<p->a.xueli;
for(int l=0;l<9;l++)
kk[l].hidebutton(hOut,false);
tal=true;
break;
}
}
if(tal)
break;
}
}
if(mouseclickl(hOut,hIn,a[7],mouseRec))
{
pos=a[7].pos1;
pos.X+=8;
posa=pos;
posa.X+=20;
clearscreen(hOut,pos,posa);
SetConsoleCursorPosition(hOut,pos);
cin>>p->a.work;
}
if(mouseclickl(hOut,hIn,a[8],mouseRec))
{
pos=a[8].pos1;
pos.X+=8;
posa=pos;
posa.X+=20;
clearscreen(hOut,pos,posa);
SetConsoleCursorPosition(hOut,pos);
cin>>p->a.zhiche;
}if(mouseclickl(hOut,hIn,a[9],mouseRec))
{
pos=a[9].pos1;
pos.X+=8;
posa=pos;
posa.X+=20;
clearscreen(hOut,pos,posa);
SetConsoleCursorPosition(hOut,pos);
cin>>p->a.birthaddress;
}
if(mouseclickl(hOut,hIn,b[1],mouseRec))
{
p->a=k;
return ;
}
if(mouseclickl(hOut,hIn,b[0],mouseRec))
{
if(strcmp(k.name,p->a.name))
{
if(p->lchild)
p=p->lchild;
if(p->parent)
strcpy(p->a.parentname,p->parent->a.name);
while(p->rchild)
{
p=p->rchild;
strcpy(p->a.parentname,p->parent->a.name);
}
}
return ;
}
}
}
bitree search2(bitree t,bitnode*k) //按基本信息查询
{
bitnode*s,*stack[300],*p;
bitnode *u;
u=new bitnode;
u=k;
bitree q=u;
int top=0;
stack[top]=t;
while(top>=0)
{
s=stack[top--];
while(s)
{
int a[10]; //用于判断用户输入的每个基本项是否与树中结点对应的项相同
int j=0;
for(j=0;j<10;j++)
{
a[j]=0;
}
j=0;
if(strcmp(k->a.name,"###"))
{
if(!strcmp(k->a.name,s->a.name)) //姓名
{
a[j]=1; //姓名相同
}
j++;
}
if(strcmp(k->a.sex,"###")) //性别
{
if(!strcmp(k->a.sex,s->a.sex))
{
a[j]=1; //性别相同
}
j++;
}
if(strcmp(k->a.stature,"###")) //身高
{
if(!strcmp(k->a.stature,s->a.stature))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.consort,"###")) //配偶
{
if(!strcmp(k->a.consort,s->a.consort))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.birthday,"###")) //生日
{
if(!strcmp(k->a.birthday,s->a.birthday))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.deathday,"###"))
{
if(!strcmp(k->a.deathday,s->a.deathday)) //死亡日期
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.xueli,"###")) //学历
{
if(!strcmp(k->a.xueli,s->a.xueli))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.work,"###")) //职业
{
if(!strcmp(k->a.work,s->a.work))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.zhiche,"###")) //职称
{
if(!strcmp(k->a.zhiche,s->a.zhiche))
{
a[j]=1;
}
j++;
}
if(strcmp(k->a.birthaddress,"###")) //出生地
{
if(!strcmp(k->a.birthaddress,s->a.birthaddress))
{
a[j]=1;
}
j++;
}
int x=0;
if(j==1)
x=a[0];
else
for(int i=0;i<j-1;i++) //用于判断用户输入的每个基本项是否与树中结点对应的项相同
{
x=a[i]*a[i+1];
}
if(x) //但x为1 时则该节点符合条件将其加入链表q中
{
p=new bitnode;
p->a=s->a;
u->lchild=p;
u=p;
}
// cout<<s->a.name<<endl;
if(s->rchild)
stack[++top]=s->rchild;
s=s->lchild;
}
}
u->lchild=NULL;
return q;
}
bitnode* searchperson(HANDLE hOut,bitree t)
{
bitnode*p=new bitnode;
strcpy(p->a.birthaddress,"###");
strcpy(p->a.birthday,"###");
strcpy(p->a.consort,"###");
strcpy(p->a.zhiche,"###");
strcpy(p->a.deathday,"###");
strcpy(p->a.name,"###");
strcpy(p->a.sex,"###");
strcpy(p->a.stature,"###");
strcpy(p->a.work,"###");
strcpy(p->a.xueli,"###");
bitree q; //用于存放找到的节点
p=cinnode1(p,hOut);
if(!p)
{
p=new bitnode;
strcpy(p->a.parentname,"######");
return p;
}
//q=new bitnode;
//q->a=p->a;
q=search2(t,p);
if(!q->lchild)
q=NULL;
else
{
q=q->lchild;
}
return q;
}
void search1(bitree t) //按亲属关系查询
{
HANDLE hOut,hIn;
INPUT_RECORD mouseRec;
DWORD res;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);// 获取标准输出设备句柄
hIn = GetStdHandle(STD_INPUT_HANDLE); // 获取标准输入设备句柄
button x_,y_,z_,h;
COORD posx_={28,13};
x_.createbutton(posx_,"父亲",14,236,hOut);
posx_.X+=10;
y_.createbutton(posx_,"孩子",14,236,hOut);
posx_.X+=10;
z_.createbutton(posx_,"兄弟",14,236,hOut);
COORD posh2={47,9};
h.createbutton(posh2," ↖ ",14,236,hOut);
COORD p1={23,14},p2={100,60},p0={23,18};
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
mousemove1(hOut,hIn,x_,mouseRec);
mousemove1(hOut,hIn,y_,mouseRec);
mousemove1(hOut,hIn,z_,mouseRec);
mousemove(hOut,hIn,h,mouseRec);
if(mouseclickl(hOut,hIn,h,mouseRec))
{
return;//返回
}
if(mouseclickl(hOut,hIn,x_,mouseRec))
{
posx_.X=28;
posx_.Y=15;
//按父亲查询
SetConsoleCursorPosition(hOut,posx_);
char name[20];
cout<<"输入父亲的姓名:";
cin>>name;
bitree p;
p=search(t,name);
if(p)
{
if(p->lchild)
{
p=p->lchild;
posx_.Y+=2;
SetConsoleCursorPosition(hOut,posx_);
cout<<"查询结果:";
bitree q;
q=p;
int n=0;
while(q)
{
n++;
q=q->rchild;
}
button *aa=new button[n];
posx_.X+=10;
int i=0;
while(p)
{
aa[i].createbutton(posx_,p->a.name,14,236,hOut);
posx_.X+=10;
p=p->rchild;
i++;
}
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
for(int j=0;j<n;j++)
{
mousemove1(hOut,hIn,aa[j],mouseRec);
}
for(int k=0;k<n;k++)
{
if(mouseclickl(hOut,hIn,aa[k],mouseRec))
{
clearscreen(hOut,p0,p2);
coutnode(search(t,aa[k].buttonname),hOut);
}
}
mousemove(hOut,hIn,h,mouseRec);
if(mouseclickl(hOut,hIn,h,mouseRec))
{
clearscreen(hOut,p1,p2);
break;
}
}
}
else
{
clearscreen(hOut,p1,p2);
frame2(hOut,hIn,"查无此人!!");
}
}
else
{
clearscreen(hOut,p1,p2);
strcat(name,"不在家谱中");
frame2(hOut,hIn,name);
}
}
if(mouseclickl(hOut,hIn,y_,mouseRec))
{
//按孩子查询
posx_.X=28;
posx_.Y=15;
SetConsoleCursorPosition(hOut,posx_);
cout<<"输入孩子的姓名:";
char cname[20];
cin>>cname;
bitree p;
p=search(t,cname);
if(p)
{
p=search(t,p->a.parentname);
if(p)
{
posx_.Y+=2;
button c;
SetConsoleCursorPosition(hOut,posx_);cout<<"查询结果:";
posx_.X+=12;
c.createbutton(posx_,p->a.name,14,236,hOut);
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
mousemove1(hOut,hIn,c,mouseRec);
mousemove(hOut,hIn,h,mouseRec);
if(mouseclickl(hOut,hIn,h,mouseRec))
{
clearscreen(hOut,p1,p2);
break;
}
if(mouseclickl(hOut,hIn,c,mouseRec))
{
coutnode(p,hOut);
}
}
}
else
frame2(hOut,hIn,"查无此人!!");
}
else
{
strcat(cname,"不在家谱中");
frame2(hOut,hIn,cname);
}
}
if(mouseclickl(hOut,hIn,z_,mouseRec))
{
//按兄弟查询
posx_.X=28;
posx_.Y=15;
SetConsoleCursorPosition(hOut,posx_);
cout<<"输入兄弟的姓名:";
char bname[20];
cin>>bname;
bitree p;
p=search(t,bname);
if(p)
{
p=search(t,p->a.parentname);
p=p->lchild;
if(p->rchild)
{
posx_.Y+=2;
SetConsoleCursorPosition(hOut,posx_);
cout<<"查询结果:";
posx_.X+=10;
int n=0;
bitree q=p;
while(q)
{
n++;
q=q->rchild;
}
n--;
button *aa=new button[n];
int i=0;
while(p)
{
if(strcmp(p->a.name,bname))
{
aa[i++].createbutton(posx_,p->a.name,14,236,hOut);
posx_.X+=10;
}
p=p->rchild;
}
for(;;)
{
ReadConsoleInput(hIn, &mouseRec, 1,&res);
for(int j=0;j<n;j++)
{
mousemove1(hOut,hIn,aa[j],mouseRec);
}
for(int k=0;k<n;k++)
{
if(mouseclickl(hOut,hIn,aa[k],mouseRec))
{
clearscreen(hOut,p0,p2);
coutnode(search(t,aa[k].buttonname),hOut);
}
}
mousemove(hOut,hIn,h,mouseRec);
if(mouseclickl(hOut,hIn,h,mouseRec))
{
clearscreen(hOut,p1,p2);
break;
}
}
}
else
{
clearscreen(hOut,p1,p2);
frame2(hOut,hIn," 查无此人!!");
}
}
else
{
clearscreen(hOut,p1,p2);
strcat(bname,"不在家谱中");
frame2(hOut,hIn,bname);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -