❶ 我們的老師要我們用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(); //退出系統的時候,把數據保存到文件
}