课程设计C++程序文档格式.docx
《课程设计C++程序文档格式.docx》由会员分享,可在线阅读,更多相关《课程设计C++程序文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
xh,p->
xm,p->
cs.nian,p->
cs.yue,p->
cs.ri,p->
dh,p->
zz,p->
sc)
/*记录输出*/
#defineN100
/*最多记录*/
typedefstruct
{intnian;
intyue;
intri;
}RIQI;
{charxh[15];
/*学号*/
charxm[15];
/*姓名*/
RIQIcs;
/*出生日期*/
chardh[15];
/*电话*/
charzz[20];
/*住址*/
charsc;
/*删除逻辑标记,*为删除*/
}JILU;
/*结构体类型定义*/
intShuRu(JILU[],int);
/*输入,包含添加功能*/
voidChaXun(JILU[],int);
/*查询*/
voidCha_JiLuHao(JILU[],int);
/*按记录号查询*/
voidCha_XueHao(JILU[],int);
/*按学号查询*/
voidCha_XingMing(JILU[],int);
/*按姓名查询*/
voidCha_NianLing(JILU[],int);
/*按年龄查询*/
voidCha_QuanBu(JILU[],int);
/*查询全部*/
intShanChu(JILU[],int);
/*删除*/
voidShan_JiLuHao(JILU[],int);
/*按记录号删除*/
voidShan_XueHao(JILU[],int);
/*按学号删除*/
voidShan_XingMing(JILU[],int);
/*按姓名删除*/
voidShan_NianLing(JILU[],int);
/*按出生年份删除*/
voidShan_QuanBu(JILU[],int);
/*删除全部记录*/
voidShan_HuiShouZhan(JILU[],int);
/*回收站察看*/
voidShan_CheXiao(JILU[],int);
/*撤销删除*/
intShan_WuLi(JILU[],int);
/*清空回收站*/
voidmima(void);
/*密码检验*/
voidstop(void);
/*暂停*/
voidCunPan(JILUBiao1[],intk_Biao1,charWenJian[]);
/*存盘*/
intDaoRu(JILUBiao1[],charWenJian[]);
/*导入:
从文件WenJian到表Biao1*/
voidJiaoHuan(JILUBiao1[],int,int);
/*交换:
表Biao1内两个下标的元素*/
voidPaiXu(JILUBiao1[],intk_Biao1);
/*排序:
表Biao1内k_Biao1个记录*/
voidTongJi(JILUBiao1[],intk_Biao1);
/*统计:
voidstop(void)
{P("
\n\n按任一键继续..."
);
getch();
}
voidmain(void)/*********主函数*********/
{charc;
inti,j;
JILUBiao1[N];
/*表1,最多纪录N*/
intk_Biao1=0;
/*表1实际记录数*/
charWenJian[20];
/*数据库文件名,*/
/*system("
graftabl936"
*//*WinTC设置汉字环境*/
system("
CLS"
mima();
/*密码检验*/
P("
\n\n\t\t\t数据文件名=?
"
gets(WenJian);
k_Biao1=DaoRu(Biao1,WenJian);
/*自动导入*/
for(;
;
{system("
\n\n\n\n\n\n"
\t\t\t**************************\n"
\t\t\t**\n"
\t\t\t*主菜单*\n"
\t\t\t*F1.输入*\n"
\t\t\t*F2.查询*\n"
\t\t\t*F3.删除*\n"
\t\t\t*F4.存盘*\n"
\t\t\t*F5.导入*\n"
\t\t\t*F6.排序*\n"
\t\t\t*F7.统计*\n"
\t\t\t*Esc.结束*\n"
\t\t\t**************************\n\n"
\t\t\t选择?
c=getch();
if(c==0)c=getch();
if(c==27)break;
/*ESC*/
switch(c)
{case59:
k_Biao1=ShuRu(Biao1,k_Biao1);
break;
/*F1*/
case60:
ChaXun(Biao1,k_Biao1);
/*F2*/
case61:
k_Biao1=ShanChu(Biao1,k_Biao1);
break;
/*F3*/
case62:
CunPan(Biao1,k_Biao1,WenJian);
/*F4*/
case63:
k_Biao1=DaoRu(Biao1,WenJian);
/*F5*/
case64:
PaiXu(Biao1,k_Biao1);
/*F6*/
case65:
TongJi(Biao1,k_Biao1);
/*F7*/
puts("
\n\n\t\t保存数据?
(N--不保存!
否则保存)"
if(c!
='
n'
&
c!
N'
)CunPan(Biao1,k_Biao1,WenJian);
intShanChu(JILUBiao1[],intk_Biao1)/*****删除主控模块*****/
{
charc;
\t\t\t1.按记录号删除\n"
\t\t\t2.按学号删除\n"
\t\t\t3.按姓名删除\n"
\t\t\t4.按出生年份删除\n"
\t\t\t5.删除全部记录\n"
\t\t\t6.回收站察看\n"
\t\t\t7.撤销删除\n\n"
\t\t\t9.清空回收站(不可恢复!
)\n\n"
\t\t\tEsc.返回\n\n"
\n\t\t\t选择?
{case'
1'
:
Shan_JiLuHao(Biao1,k_Biao1);
case'
2'
Shan_XueHao(Biao1,k_Biao1);
3'
Shan_XingMing(Biao1,k_Biao1);
4'
Shan_NianLing(Biao1,k_Biao1);
5'
Shan_QuanBu(Biao1,k_Biao1);
6'
Shan_HuiShouZhan(Biao1,k_Biao1);
7'
Shan_CheXiao(Biao1,k_Biao1);
9'
k_Biao1=Shan_WuLi(Biao1,k_Biao1);
returnk_Biao1;
}
voidShan_JiLuHao(JILUBiao1[],intk_Biao1)/*按记录号逻辑删除*/
inti,n1,n2;
JILU*p;
\n\n\n\n\t\t请输入起始记录流水号:
"
scanf("
%d"
&
n1);
\n\n\t\t请输入结束记录流水号:
n2);
if(n1<
0)n1=0;
if(n1>
=k_Biao1)return;
if(n2<
0)return;
if(n2>
=k_Biao1)n2=k_Biao1;
n1)return;
for(p=&
Biao1[n1],i=n1;
i<
=n2;
i++,p++)p->
sc='
*'
stop();
voidShan_XueHao(JILUBiao1[],intk_Biao1)/*按学号逻辑删除*/
charx[20];
inti;
\n\n\n\n\t\t请输入学号:
%s"
x);
for(i=0,p=Biao1;
k_Biao1;
i++,p++)if(strcmp(p->
xh,x)==0)p->
voidShan_XingMing(JILUBiao1[],intk_Biao1){}
voidShan_NianLing(JILUBiao1[],intk_Biao1){}
voidShan_QuanBu(JILUBiao1[],intk_Biao1){}
voidShan_HuiShouZhan(JILUBiao1[],intk_Biao1)/*回收站察看*/
PBT;
for(p=Biao1,i=0;
i++,p++)if(p->
sc=='
)PJL;
voidShan_CheXiao(JILUBiao1[],intk_Biao1)/*撤销删除*/
JILU*p,*q;
for(p=Biao1,q=Biao1+k_Biao1;
p<
q;
p++)
{
if(p->
'
)continue;
PJL;
撤销删除?
(Y/N)"
if(c=='
Y'
||c=='
y'
)p->
intShan_WuLi(JILUBiao1[],intk_Biao1)/*物理删除(清空回收站)*/
JILU*p1,*p2,*q;
p1=p2=Biao1;
q=Biao1+k_Biao1;
p1<
p1++)
if(p1->
if(p1==p2){p2++;
continue;
strcpy(p2->
xh,p1->
xh);
xm,p1->
xm);
p2->
cs.nian=p1->
cs.nian;
cs.yue=p1->
cs.yue;
cs.ri=p1->
cs.ri;
dh,p1->
dh);
zz,p1->
zz);
sc=p1->
sc;
p2++;
printf("
\n\n\t\t回收站已成功清空了%d条记录\n"
p1-p2);
k_Biao1-=p1-p2;
voidmima(void)/*****密码检验*****/
intj,n;
chara[80];
for(n=1;
n<
=3;
n++)
switch(n)
{case1:
P("
\n\n\n\n\t\t\t密码(以Enter结束)=?
case2:
\n\n\n\n\t密码错误,请重新输入密码(以Enter结束)=?
case3:
\n\n\n\n\t密码错误,请最后一次输入密码(以Enter结束)=?
for(j=0;
j++)
{a[j]=getch();
if(a[j]==13){a[j]='
\0'
elseputchar('
if(strcmp(a,MIMA)==0)return;
if(n>
3)exit
(1);
intShuRu(JILUBiao1[],intk_Biao1)/*****输入模块*****/
Biao1[k_Biao1];
k_Biao1++,p++)
\n学号(输入一个“#”则结束输入)=?
p->
if(strcmp(p->
xh,"
#"
)==0)break;
姓名=?
出生日期(如198024)=?
%d%d%d"
p->
cs.nian,&
cs.yue,&
cs.ri);
电话=?
住址=?
p->
voidChaXun(JILUBiao1[],intk_Biao1)/*****查询主控模块*****/
\t\t\t1.按记录号查询\n"
\t\t\t2.按学号查询\n"
\t\t\t3.按姓名查询\n"
\t\t\t4.按出生年份查询\n\n"
\t\t\t9.查询全部\n\n"
Cha_JiLuHao(Biao1,k_Biao1);
Cha_XueHao(Biao1,k_Biao1);
Cha_XingMing(Biao1,k_Biao1);
Cha_NianLing(Biao1,k_Biao1);
Cha_QuanBu(Biao1,k_Biao1);
voidCha_JiLuHao(JILUBiao1[],intk_Biao1)/*按记录号查询*/
sc!
voidCha_XueHao(JILUBiao1[],intk_Biao1)/*按学号查询*/
xh,x)==0&
voidCha_XingMing(JILUBiao1[],intk_Biao1)/*按姓名查询*/
voidCha_NianLing(JILUBiao1[],intk_Biao1)/*****按年龄查询*****/
JILU*a;
\n\n\n\n\t\t请输入出生年份:
a->
cs,a->
cs)==0&
voidCha_QuanBu(JILUBiao1[],intk_Biao1)/*****查询全部*****/
i++,p++)PJL;
voidCunPan(JILUBiao1[],intk_Biao1,charWenJian[])/*存盘*/
FILE*fp;
if((fp=fopen(WenJian,"
wb"
))==NULL)
{puts("
\n\n\t\t文件打开错误!
stop();
return;
fwrite(p,sizeof(JILU),1,fp);
fclose(fp);
\n\n\t\t已成功保存%d条记录\n"
k_Biao1);
intDaoRu(JILUBiao1[],charWenJian[])/*导入*/
intk_Biao1;
rb"
\n\n\t\t\t文件打开错误!
return0;
for(p=Biao1;
!
feof(fp);
fread(p,sizeof(JILU),1,fp);
k_Biao1=p-Biao1-1;
\n\n\t\t已成功导入%d条记录\n"
voidJiaoHuan(JILUBiao1[],intj,intk)/*交换公共数组Biao1内元素j与元素k*/
JILUx;
strcpy(x.xh,Biao1[j].xh);
strcpy(Biao1[j].xh,Biao1[k].xh);
strcpy(Biao1[k].xh,x.xh);
strcpy(x.xm,Biao1[j].xm);
strcpy(Biao1[j].xm,Biao1[k].xm);
strcpy(Biao1[k].xm,x.xm);
x.cs.nian=Biao1[j].cs.nian;
Biao1[j].cs.nian=Biao1[k].cs.nian;
Biao1[k].cs.nian=x.cs.nian;
x.cs.yue=Biao1[j].cs.yue;
Biao1[j].cs.yue=Biao1[k].cs.yue;
Biao1[k].cs.yue=x.cs.yue;
x.cs.ri=Biao1[j].cs.ri;
Biao1[j].cs.ri=Biao1[k].cs.ri;
Biao1[k].cs.ri=x.cs.ri;
strcpy(x.dh,Biao1[j].dh);
strcpy(Biao1[j].dh,Biao1[k].dh);
strcpy(Biao1[k].dh,x.dh);
strcpy(x.zz,Biao1[j].zz);
strcpy(Biao1[j].zz,Biao1[k].zz);
strcpy(Biao1[k].zz,x.zz);
x.sc=Biao1[j].sc;
Biao1[j].sc=Biao