当前位置:首页 » 编程语言 » c语言饭卡管理系统
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言饭卡管理系统

发布时间: 2022-07-17 17:55:39

❶ 我们的老师要我们用c语言写一个学生打卡的系统,不能用C++写,大家给点提示吧

我们老师也说过..不过后来没消息了..
本来我还想参加看看怎么搞的呢..
哎..你有机会啊..多请教老师了

❷ c语言while用法

这是程序设计中典型的通过循环的菜单功能。。
由于您没有给完整上下文,所以无法做出正确的判断。
但估计m的作用是保存从用户输入处得到的选项。
由于c规定,用Int表示布尔型时,任何非0的int都表示true,所以,只要用户输入的是1、2、3、4、5、6、7...中的一种,循环就会继续。。然后通过switch对m进行判断,执行对应操作。。当m=0时,循环结束,退出。。
建议你为了方便理解,可以把代码改成

void main()
{
int m;
m=menu(),
while(m)
{
switch(m)
{
case 1:
create_file();
break;
case 2:
buy();

PS:中间的逗号是逗号运算符,连接并列成分。m=menu()其实并不多余,只是位置放的不易理解!

❸ 食堂饭卡管理系统首页应有哪些内容

饭卡属于非接触式ID卡,或称射频卡,其核心部分是一个带有电磁感应线圈的微型计算机芯片。饭卡的使用离不开读卡器。刷卡时,读卡器从饭卡读取到一串数字,即卡号。
任何两张饭卡的卡号都不相同,具有唯一性,好比指纹。也就是说,饭卡可以作为身份认证来使用。
当读卡器读取到卡号后,会进入数据库系统,依据卡号找到相应的个人信息和数据,并进行相关操作。(即,我们所说的“饭卡里的钱”实际上是数据库中的相应记录。)
如果在食堂使用饭卡,进入的是校园一卡通系统;如果在计算机学院机房使用饭卡,进入的是机房管理系统。所以在食堂充的钱只能在食堂就餐,在机房充的钱只能在机房自由上机。这两个系统相互独立,没有关联,只不过都是用饭卡作为身份认证而已。

❹ 求一个C语言课设,是食堂饭卡管理系统的。食堂饭卡暴扣学生各种信息——姓名学号院系,余额等;不少于10人

这个。。。不太难。
自己找本带有例子c语言的 书看看。
用到也就是一维数组,文件FILE指针,结构体。
c中的多维数组和指针都可以不用。
自己钻研一下吧,三五天的 事。
有c的课设,说明是跟计算机相关的吧,,,,c可是基础啊。。。

❺ c++学生饭卡管理系统。题目:饭卡充值管理系统功能:录入饭卡信息(包

WX:DtSquarepants,注明c++

❻ 急求C语言、C++ 编写的饭卡管理系统代码,最好每个版块附上一段分析,谢了

这个最好自己写,但是我有一个员工信息的代码,含注释,与这个很相似,只要稍加修改即可。

#include <stdio.h>
#include <stdlib.h>
#include <windows.h> //清屏函数头文件
#include <string.h>
struct Stuff
{
char number[10]; //员工编号
char name[10]; //员工姓名
char sex[8]; //员工性别
char borth[10]; //员工生日
char degree[20]; //员工学历
char business[20]; //员工职务
char phone[15]; //员工电话
char place[50]; //员工住址
char con[50]; //判断关键字专用
struct Stuff *next;
};

char Menu(void); //菜单显示
struct Stuff *App(struct Stuff *head); //添加
void Sort(struct Stuff *head); //排序
struct Stuff *Ser(struct Stuff *head); //查找
void Chn(struct Stuff *head,char n[10]); //更改
void Scpy(char *p,char *q); //排序中用于交换员工信息
struct Stuff *Del(struct Stuff *head,char n[10]); //删除
int Sel(char ch,struct Stuff *p,struct Stuff *q); //判断排序及关键字专用函数
void Prf(struct Stuff *head); //输出
void Fre(struct Stuff *head); //释放
int i=1; //定义全局变量,实现实时员工人数统计

int main(void)
{
char n[10];
struct Stuff *head=NULL; //链表头指针定义
while(1)
{
switch(Menu())
{
case '1':
printf("请输入员工信息,直接输入'#'结束\n");
head=App(head);
break;
case '2':
Sort(head);
break;
case '3':
head=Ser(head);
break;
case '4':
printf("员工信息如下:\n");
Prf(head);
break;
case '5':
printf("请输入员工编号:");
scanf("%s",n);
Chn(head,n);
break;
case '6':
printf("请输入员工编号:");
scanf("%s",n);
head=Del(head,n);
break;
case '0':
printf("欢迎下次光临,88!\n");
exit(0);
default:
printf("输入错误,请重新输入!\n");
}
fflush(stdin); //清楚缓冲区
printf("按任意键继续~");
getchar();
system("cls"); //清屏效果
}
Fre(head);

return 0;
}
//菜单函数
char Menu(void)
{
char ch;
printf("------------请选择-----------\n");
printf("1.添加员工信息\n2.员工信息排序\n3.查找员工信息\n4.输出员工信息\n5.更改员工信息\n6.删除员工信息\n0.退出\n-----------------------------\n");
scanf(" %c",&ch);
return ch;
}
//添加成员函数
//输入参数:链表头指针
//返回参数:链表头指针
struct Stuff *App(struct Stuff *head)
{
struct Stuff *p=NULL,*q=head;
while(i)
{
p=(struct Stuff *)malloc(sizeof(struct Stuff)); //申请结构体空间
if(p==NULL)
{
printf("内存不够!\n");
exit(0);
}
p->next =NULL; //指针域为空
printf("请输入第%d名员工:\n",i);
printf(" 编号 | 姓名 | 性别 | 出生年月 | 学历 | 职务 | 电话 | 住址 :\n");
fflush(stdin);
scanf("%s",p->number );
if(!strcmp(p->number ,"#"))
{
free(p); //释放不需要的结构体内存
break;
}
else
{
++i;
scanf("%s%s%s%s%s%s%s",p->name ,p->sex ,p->borth ,p->degree ,p->business ,p->phone ,p->place );
p->con[0]='\0'; //防止后面判断出现随机值
if(head==NULL)
head=p;
else
{
while(q->next !=NULL) //防止结束后再次输入时出现问题
q=q->next ;
q->next =p;
}
q=p; //每次都加在链表尾
}
}
return head;
}

//排序函数
//输入参数:头指针
void Sort(struct Stuff *head)
{
char ch;
struct Stuff *p,*q,*r;
while(1)
{
printf("请选择排序条件:1.编号2.姓名3.性别4.出生年月5.学历6.职务7.电话8.地址0.退出\n");
scanf(" %c",&ch);
if(ch=='0')
break;
if(ch<'1'||ch>'8')
{
printf("输入错误,请重新输入!\n");
continue;
}
p=head;
while(p->next!=NULL) //选择排序
{
q=p->next;
r=p;
while(q!=NULL)
{
if(Sel(ch,r,q)) //调用判断函数
r=q;
q=q->next;
}
if(r!=p) //交换内容
{
Scpy(r->number,p->number);
Scpy(r->name,p->name);
Scpy(r->sex,p->sex);
Scpy(r->borth,p->borth);
Scpy(r->degree,p->degree);
Scpy(r->business,p->business);
Scpy(r->phone,p->phone);
Scpy(r->place,p->place);
}
p=p->next;
}
Prf(head); //输出
}
}

//交换函数
void Scpy(char *p,char *q)
{
char c[50];
strcpy(c,p);
strcpy(p,q);
strcpy(q,c);
}

//判断函数
//输出参数:1为真,0为假
int Sel(char ch,struct Stuff *p,struct Stuff *q)
{
switch(ch) //实现各个关键字查找
{
case '1':
return strcmp(q->number ,p->number )<0||strcmp(q->con ,p->number )==0 ; //排序条件及查找条件
case '2':
return strcmp(q->name ,p->name )<0||strcmp(q->con ,p->name )==0 ;
case '3':
return strcmp(q->sex ,p->sex )<0||strcmp(q->con ,p->sex )==0 ;
case '4':
return strcmp(q->borth ,p->borth)<0 ||strcmp(q->con ,p->borth )==0 ;
case '5':
return strcmp(q->degree ,p->degree )<0||strcmp(q->con ,p->degree )==0 ;
case '6':
return strcmp(q->business ,p->business )<0||strcmp(q->con ,p->business)==0 ;
case '7':
return strcmp(q->phone ,p->phone )<0 ||strcmp(q->con ,p->phone)==0;
case '8':
return strcmp(q->place ,p->place )<0||strcmp(q->con ,p->place )==0;
default :
exit(0);
}
}

//查找函数
struct Stuff *Ser(struct Stuff *head)
{
struct Stuff *p=NULL,*q,a={"\0","\0","\0","\0","\0","\0","\0","\0"}; //防止判断时错误
int flag; //查找判断
char ch,sh;
q=&a;
while(1)
{
printf("请输入要查找的条件:1.编号2.姓名3.性别4.出生年月5.学历6.职务7.电话8.住址0.退出\n");
scanf(" %c",&ch);
if(ch=='0')
break;
if(ch<'1'||ch>'8')
{
printf("输入错误,请重新输入!\n");
continue;
}
fflush(stdin);
printf("请输入:");
gets(q->con );
p=head; //指向表头
flag=0;
while(p!=NULL)
{
if(Sel(ch,p,q))
{
printf("员工信息如下:\n");
printf(" 编号 | 姓名 | 性别 | 出生年月 | 学历 | 职务 | 电话 | 住址 \n%s %s %s %s %s %s %s %s\n"
,p->number ,p->name ,p->sex ,p->borth ,p->degree ,p->business ,p->phone ,p->place );
printf("是否需要:1.更改 2.删除 3.继续\n");
scanf(" %c",&sh);
if(sh=='1')
Chn(head,p->number); //调用更改函数
else if(sh=='2')
head=Del(head,p->number); //调用删除函数,得到的head必须return
flag=1;
break;
}
p=p->next ;
}
if(flag==0)
printf("没有找到该员工信息!\n");
}
return head;
}

//更改函数
//输入参数:n[10] 为员工编号
void Chn(struct Stuff *head,char n[10])
{
struct Stuff *p=head;
int flag=0;
if(head==NULL)
printf("未找到员工信息!\n");
else
{
while(p!=NULL)
{
if(!strcmp(p->number,n))
{
printf("请输入新的信息:\n编号|姓名|性别|出生年月|学历|职务|电话|住址\n");
scanf("%s%s%s%s%s%s%s%s",p->number ,p->name ,p->sex ,p->borth ,p->degree ,p->business ,p->phone ,p->place );
printf("员工信息如下:\n");
flag++;
break;
}
p=p->next;
}
if(flag==0)
printf("未找到该员工信息!\n");
}
Prf(head);
}

//删除函数
//输入参数:n为员工编号
//输出参数:头指针
struct Stuff *Del(struct Stuff *head,char n[10])
{

struct Stuff *p,*pr;
int flag;
flag=0;
p=head,pr=head;
if(head==NULL)
printf("未找到员工信息!\n");
else
{
while(strcmp(p->number ,n)&&p->next !=NULL)
{
pr=p;
p=p->next ;
}
if(!strcmp(p->number ,n))
{
if(p==head)
head=p->next ;
else
pr->next=p->next ;
free(p);
printf("删除成功!\n");
i--;
}
else
printf("未找到员工信息!\n");
}
Prf(head);
return head;
}

//输出函数
void Prf(struct Stuff *head)
{
struct Stuff *p=head;
int i=1;
while(p!=NULL)
{
printf("%d. %s %s %s %s %s %s %s %s\n"
,i++,p->number ,p->name ,p->sex ,p->borth ,p->degree ,p->business ,p->phone ,p->place);
p=p->next ;
}
}

//释放函数
void Fre(struct Stuff *head)
{
struct Stuff *p;
while(head!=NULL)
{
p=head;
head=head->next ;
free(p);
}
}
只有400行不到,分的如果你真的看懂了,就应该自己写,程序是死的人是活的,自己动手改改吧。

❼ 200分求救!C语言饭卡管理系统代码!

花半小时简单的写了一下,你看看行不行.
最开始运行程序的时候,要先建立文件,就是要选菜单1.
#include <stdio.h>
struct Card
{
int ID; //卡号
char name[20];
double value; //金额
int flag; //挂失信息
}
card[1000]; //假设最多1000张
int counts; //当前已有饭卡数量
FILE * fp;

int menu()
{
int choose;
printf("|-------------------------------|\n");
printf("| 请输入选项编号(0--7) |\n");
printf("|-------------------------------|\n");
printf("| 0——退出 |\n");
printf("| 1——建立饭卡文件 |\n");
printf("| 2——买饭 |\n");
printf("| 3——续钱 |\n");
printf("| 4——添加新饭卡 |\n");
printf("| 5——注销旧饭卡 |\n");
printf("| 6——设置与解除挂失 |\n");
printf("| 7——显示全部饭卡信息 |\n");
printf("|-------------------------------|\n");
scanf("%d",&choose);
return choose;
}

void write_file()
{
int i;
FILE * f;
f=fopen("card.dat","w");
for(i=0;i<counts;i++)
fprintf(f,"%d %s %lf %d\n",card[i].ID,card[i].name,card[i].value,card[i].flag);
fclose(f);
}

void create_file() //如果已经存在了card.dat那么就打开该文件
{
int i=0;
fp=fopen("card.dat","r");
if(fp!=NULL) //如果已经存在
{
printf("文件已经存在!\n");
while(fscanf(fp,"%d%s%lf%d",&card[i].ID,card[i].name,&card[i].value,&card[i].flag)!=EOF)
i++;
counts=i;
fclose(fp);
return ;
}
fp=fopen("card.dat","w");
printf("输入卡号,姓名,金额,挂失信息(0/1)(卡号-1表示输入结束!):\n");
while(scanf("%d%s%lf%d",&card[i].ID,card[i].name,&card[i].value,&card[i].flag),card[i].ID!=-1)
i++;
counts=i;
fclose(fp);
write_file();
}

void buy1(int card_id,double cost)
{
int i;
for(i=0;i<counts;i++)
{
if(card[i].ID==card_id)
{
if(card[i].flag==1)
{
printf("本卡已挂失!\n");
return ;
}
if(card[i].value<5)
{
printf("金额不足!\n");
return ;
}
printf("%lf\n",card[i].value);
card[i].value-=cost;
printf("%lf\n",card[i].value);
}
}
printf("非法卡!\n");
}

void buy()
{
int id;
double v;
printf("输入卡号和消费金额:\n");
scanf("%d%lf",&id,&v);
buy1(id,v);
}

void add_value()
{
int id,i;
double v;
printf("输入卡号和续钱金额:\n");
scanf("%d%lf",&id,&v);
for(i=0;i<counts;i++)
{
if(card[i].ID==id)
{
printf("%lf\n",card[i].value);
card[i].value+=v;
printf("%lf\n",card[i].value);
printf("ok!\n");
return ;
}
}
printf("error!\n");
}

void add_card()
{
int i=counts;
printf("输入卡号,姓名,金额,挂失信息(0/1)(卡号-1表示输入结束!):\n");
while(scanf("%d%s%lf%d",&card[i].ID,card[i].name,&card[i].value,&card[i].flag),card[i].ID!=-1)
i++;
counts=i;
}

void del_card()
{
int id;
int i,j;
printf("输入要注销的卡号:\n");
scanf("%d",&id);
for(i=0;i<counts;i++)
{
if(card[i].ID==id)
{
for(j=i;j<counts-1;j++)
card[j]=card[j+1];
printf("注销成功!\n");
return ;
}
}
}

void set_flag()
{
int id,i,f;
printf("输入卡号和挂失信息(1:挂失,0:解除挂失)\n");
scanf("%d%d",&id,&f);
for(i=0;i<counts;i++)
{
if(card[i].ID==id)
{
card[i].flag=f;
printf("设置完成 !\n");
break;
}
}
}

void output()
{
int i;
printf("%6s%11s%10s%6s\n","卡号","姓名","金额","挂失");
for(i=0;i<counts;i++)
printf("%6d%11s%10.3lf%2d\n",card[i].ID,card[i].name,card[i].value,card[i].flag);
}

void main()
{
int m;
while(m=menu(),m)
{
switch(m)
{
case 1:
create_file();
break;
case 2:
buy();
break;
case 3:
add_value();
break;
case 4:
add_card();
break;
case 5:
del_card();
break;
case 6:
set_flag();
break;
case 7:
output();
break;
default:
printf("输入有误,重新输入!\n");
}
}
write_file(); //退出系统的时候,把数据保存到文件
}