600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > c语言网吧计费管理小项目 c语言网吧计费系统小项目.doc

c语言网吧计费管理小项目 c语言网吧计费系统小项目.doc

时间:2019-10-14 21:52:25

相关推荐

c语言网吧计费管理小项目 c语言网吧计费系统小项目.doc

c语言网吧计费系统小项目

系统是基于c语言写的小程序,以应付毕业项目或期末考试用。

由于用到fopen读写文件操作,编译前必须在当前文件下建立 用户信息.txt 和 充值卡.txt 两个文件,否则会报错。

效果图

#include

#include

#include

#include

#include

//定义链表

typedef struct

{

char name[20];

char mima[20];

int state;

int jine;

}user;

typedef struct lnod

{

user data;

struct lnod *next;

}lnod, *linklist;

//充值卡定义链表

typedef struct

{

char name[30];

int jine;

}kami;

typedef struct kk

{

kami data;

struct kk *next;

}kk, *kamil;

//创建链表

void createlist_l(linklist *l)

{

*l = (linklist)malloc(sizeof(lnod));

(*l)->next = NULL;

}

//插入用户信息(尾插法)

int listinset_l(linklist *l,user data)

{

linklist p = *l,q;

if (NULL==p)

return -1;

while (NULL!=p)

{

q = p;

p = p->next;

}

p = (linklist)malloc(sizeof(lnod));

p->data = data;

p->next = q->next;

q->next = p;

return 0;

}

//载入文件到链表

void filelist_l(linklist *l)

{

int i;

FILE *fp1;

user user0;

fp1 = fopen("用户信息.txt","rb");

for (i = 0;i<50;i++)

{

if (1!=fread(&user0,sizeof(user),1,fp1))

{

break;

}

listinset_l(l,user0);

}

fclose(fp1);

}

//查找制定用户是否存在

int locateelem_l(linklist l,char name[])

{

linklist p;

p = l->next;

while (p!=NULL)

{

if (!(strcmp(p->data.name,name)))

{

break;

}

p = p->next;

}

if (p == NULL)

{

return -1;

}

else

return 0;

}

//查找指定用户和密码

int locateelem_l2(linklist l,char name[],char mm[])

{

linklist p;

int a,b;

p = l->next;

while (p!=NULL)

{

a = strcmp(p->data.name,name);

b = strcmp(p->data.mima,mm);

if (a==0&&b==0)

{

//p->data.state = 1;

break;

}

p = p->next;

}

if (p == NULL)

{

return -1;

}

else

return 0;

}

//登陆后state = 1;

void gaistate_l(linklist *l,char name[])

{

linklist p;

int b;

p = (*l)->next;

while (p!=NULL)

{

b = strcmp(p->data.name,name);

if (b==0)

{

p->data.state=1;

break;

}

else

{

p = p->next;

}

}

}

//下线state = 0

void xiaxian_l(linklist *l,char name[])

{

linklist p;

int b;

p = (*l)->next;

while (p!=NULL)

{

b = strcmp(p->data.name,

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。