当前位置:首页 > C语言 教师工资管理系统设计
id=p1->id;
while(hassong(head,id,check)==1){
printf(\已经存在,请重新输入!\\n\
scanf(\ept,p1->phone,&p1->money); check = p1->name; id=p1->id; }
p2->next=p1; p2=p1;
p2->next=NULL;
printf(\继续?(Y/N):\ choice=getche(); printf(\ }
return head; }
struct message *readfile(void)/* 建立信息 */ {
char *p=\ FILE *fp;
struct message *p1,*p2,*head;
head=p2=(struct message *)malloc(N); head->next=NULL;
if ((fp=fopen(\ {
printf(\导入文件失败 ,请输入一些信息\ head=creat(); }
else{
int i=0;
p1=(struct message *)malloc(N);
while(fscanf(fp,\>sex,p1->dept,p1->phone,&p1->money)==7) {
i++;
p2->next=p1;
7
p2=p1;
p1=(struct message *)malloc(N); }
fclose(fp); if(i == 0){
head=creat(); }else{
printf(\录入完毕!共 %d 个教师信息导入成功\\n\ p2->next=NULL; getche(); }
}
return head; }
void insert (struct message *head) {
struct message *p; char *check; int id;
p=(struct message *) malloc(N);
printf(\请输入编号 姓名 年龄 性别 部门 手机号 工资***\\n\
scanf(\->phone,&p->money); check = p->name; id=p->id;
if(hassong(head,id,check)==0){ if(head->next!=NULL) {
p->next=head->next; head->next=p; }
printf(\插入成功!按任意键继续!\ }else{
printf(\该教师已经存在\ }
getche(); }
void cut(struct message *p0) {
8
int id;
struct message *p; char choice;
if(p0->next==NULL) {
printf(\信息出错!按任意键退出!\ getch(); exit(1); }
printf(\请输入要删除的编号:\ scanf(\
for(p=p0->next;p->id != id;p0=p,p=p->next); printf(\你要删除的信息如下,请确认是否删除:\\n\
printf( \编号:%d 姓名:%s 年龄:%d 性别:%s 部门:%s 手机号:%s 工资%d \\n\ printf(\是Y,否N:\ choice=getche();
if(choice=='Y'||choice=='y') {
p0->next=p->next; free(p);
printf(\删除成功!\ }
printf(\按任意键结束!\ getche(); }
int hassong(struct message *h,int id,char name[]) {
struct message *p; int flag=0;
if(h->next==NULL){ return 0; }
for(p=h->next;p!=NULL;p=p->next){ if(strcmp(p->name,name)==0) flag=1; if(p->id==id) flag=1; }
9
return flag; }
void findbyid(struct message *h) {
int n;
struct message *p;
printf(\请输入你要查找的教师编号:\ scanf(\
for(p=h->next;p!=NULL;p=p->next){ if(p->id == n){
printf(\你查找的信息如下:\\n\
printf( \编号:%d 姓名:%s 年龄:%d 性别:%s 部门:%s 手机号:%s 工资%d \\n\ printf(\按任意键继续!\ getche(); return; } }
printf(\没有找到!\\n\ printf(\按任意键继续!\ getche(); }
void updata(struct message *h) {
int n;
struct message *p;
printf(\请输入你要更新的教师编号:\ scanf(\
for(p=h->next;p!=NULL;p=p->next){ if(p->id == n){
printf(\你查找的信息如下:\\n\
printf( \编号:%d 姓名:%s 年龄:%d 性别:%s 部门:%s 手机号:%s 工资%d \\n\
printf(\请输入年龄 性别 部门 手机号 工资***\\n\
scanf(\oney);
printf(\更新成功!\ getche();
10
共分享92篇相关文档