计算机技术基础课程设计Word格式.docx
《计算机技术基础课程设计Word格式.docx》由会员分享,可在线阅读,更多相关《计算机技术基础课程设计Word格式.docx(10页珍藏版)》请在冰豆网上搜索。
通过对函数的调用、选择结构的使用以及文件方式的保存实现对人员信息的管理。
二、设计思路:
对单位人员的信息进行管理,人员信息包括姓名、性别、年龄、学历、职位、工资、健康状况等。
可对人员信息进行插入、删除、查找、修改等功能。
三、流程图:
N
Y
四、程序清单:
#include<
stdio.h>
string.h>
stdlib.h>
conio.h>
#defineN100
typedefstructemployee
{
intnum;
intposition;
charname[20];
charsex[2];
intcult;
intsalary;
intstate;
}ro;
roem[N];
voidmanage();
voidquery();
voidinput();
voiddisplay();
voidchange();
voiddel();
intchangeposition();
intchangecult();
intchangesalary();
intchangestate();
inttotal;
intp;
charpassword[10]="
05180104"
;
voidmain()
intchoice;
chars[10];
intflag=0;
intn=3;
do
{
printf("
Pleaseenterthepassword:
\n"
);
scanf("
%s"
s);
if(!
strcmp(s,password))
WELCOME!
!
\n\n\n"
flag=1;
break;
}
else
Entererror!
Pleaseenteragain:
n--;
}while(n>
0);
flag)
Byebye!
return;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
\t\tWelcometothestaffmanagesystem!
\t\tPleasechooseyouroperatetype:
======================================================\n"
\t\t1ManageSystem\n"
\t\t2QuerySystem\n"
printf("
\t\t0Quit\n"
%d"
&
choice);
switch(choice)
case1:
manage();
case2:
query();
case0:
Thankyou!
exit(0);
default:
Pleaseenteragain!
:
return;
}while
(1);
voidmanage()
intchoicemanage;
charchoice='
y'
while(choice=='
||choice=='
Y'
)
\t\tWelcometothemanagesystem!
\t\t1Inputstaffinformation\n"
\t\t2Displaystaffinformation\n"
\t\t3Changestaffinformation\n"
\t\t4Delstaffinformation\n"
\t\t0Return\n"
choicemanage);
switch(choicemanage)
input();
display();
case3:
change();
case4:
del();
case0:
Byebye!
Goon?
(y/n)"
if(toupper(choice)=='
N'
||(choice)=='
n'
printf(“Enterend!
Anykeytoreturn!
getch();
voidinput()
FILE*fp;
inti=0;
charchoiceinput='
if((fp=fopen("
employee.txt"
"
w"
))==NULL)
while(choiceinput=='
||choiceinput=='
i++;
total++;
The%dthstaff:
i);
Pleaseenternumber:
em[i].num);
Pleaseenterposition:
1boardchairman
2generalmanager
3deputymanager\n"
4departmentmanager
5engineer
6assisstant\n"
7technologicalman
8leader
9staff\n"
em[i].position);
Pleaseentername:
em[i].name);
Pleaseentersex:
em[i].sex);
Pleaseentercult:
1expert
2doctor
3master
4bachelor
5other\n"
em[i].cult);
Pleaseentersalary:
em[i].salary);
Pleaseenterbodystate:
1good
2general
3bad\n"
em[i].state);
(y/n)\n"
choiceinput);
fwrite(&
em[i],sizeof(structemployee),1,fp);
if(toupper(choiceinput)=='
)
fclose(fp);
Enterend!