让我用心把你(的赞)留下来!
案例描述
本系统是员工档案管理系统,该系统包括姓名,性别,工号,年龄。进入系统输入密码,若密码错误三次则退出程序,此外,有输入数据,查看数据,数据查询,数据保存,数据排序等多项功能
//初始密码为123456
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "malloc.h"
#define OP sizeof(stu)
typedef struct student
{
char nam[10];
int num;
char sex[4];
char age[4];
char remark[200];
struct student *next;
}stu;
stu *head=NULL;
void cin (stu *p1)
{
printf("输入姓名:");
scanf("%s",&p1->nam);
printf("\n输入工号:");
scanf("%d",&p1->num);
printf("\n输入性别:");
scanf("%s",&p1->sex);
printf("\n输入年龄:");
scanf("%s",&p1->age);
printf("\n输入备注:");
scanf("%s",&p1->remark);
}
stu *cindata()
{
stu *p1,*p2;
int i=1;
char ch;
p1=(stu *)malloc(OP);
head->next=p1;
while(i)
{
cin(p1);
printf("是否继续,输入'n'或'N'可退出,输入其他任意键则继续输入");
ch=getchar();
ch=getchar();
if(ch=='n'||ch=='N')
{
i=0;
p1->next=NULL;
}
else{
p2=p1;
p1=(stu *)malloc(OP);
p2->next=p1;
}
}
return(p1->next);
}