資源簡介
用c語言寫的一個模擬超市收銀系統的程序代碼,適合初學c語言的人
代碼片段和文件信息
/*?Note:gaohuan?and?chen?xin‘progrom.?anybody?can‘t?copy?without?copyright@BUPT?*/
#include?
#include
#include
#include
struct?chaoshi
{
int?xp;
int?id;
int?num;
long?int?day;
?
?
}goods;
struct?tuihuo
{
int?shijian;
int?shanghao;
int?chabie;
int?shu;
}things;
int?main()
{
void?hehe(int?y);?
void?name(int?x);
????FILE?*st;FILE?*sp;
char?ID[7]ID1[]=“guest“ID2[]=“admin“;
char?mima[10]=“turboc“mima2[7];
????int?profit[10]={53250911111122};
int?a=0ijchoose3salesbc=0choose=-1choose4?u=0total=0ns
pay=0input=0payback=0findidinput2=0;
int?price[10]={1510200038042232102}pchoose1mqzf;
static?int?ticket;
static?long?int?date=20110901;
????static?int?stock[10];
????int?stocks[10]={1000100010001000100010001000100010001000};
int?sale[10]tkprofits[10];
int?tock[10];
int?ip[10]={0123456789};
?stock[0]=1000;stock[1]=1000;stock[2]=1000;stock[3]=1000;
?stock[4]=1000;stock[5]=1000;stock[6]=1000;stock[7]=1000;stock[8]=1000;stock[9]=1000;
?while(1)
?{
? if(choose==0)
? break;
????srand(time(NULL));
????printf(“請輸入您的?ID?(guest?or?admin)?:“);
???
???
?????scanf(“%s“ID);
???????
???? if(strcmp(IDID1)==0)
??????? ???{
??????? ??a=1;b=0;
??????? ???}
??????? else?if(strcmp(IDID2)==0)
???????????{
??????? ??a=1;b=1;
??????? ???}
??????? else
???????????{
??????? ?????a=0;
?????????????printf(“\n您輸入的ID有誤\n“);?
?????????????printf(“?請再次輸入?ID(guest?or?admin):“);
????????????}
??????? while(a!=1)
??????? {
???????
??????? scanf(“%s“ID);
???????
????????????????if(strcmp(IDID1)==0)
??????????????? {
????????????????? a=1;b=0;
??????? ????????????break;
??????? ????????}
????????????? else?if(strcmp(IDID2)==0)
??????? ????????{
???????????????? a=1;b=1;
??????? ????????????break;
??????? ????????}
???????????? else
????????????? {
????????????????????printf(“?笨蛋輸錯了吧^o^\n“);?
????????????????????printf(“?請再次輸入?ID(guest?or?admin):“);
??????? ????????}
??????? ??}/*end?the?while*/
???????
??????printf(“\n請輸入密碼(turboc)?:\n“);
??????
?????????for(i=0;i<10;i++)
???????{
??? ??????mima2[i]=getch();
??????????putchar(‘*‘);
??????????if(mima2[i]==‘\r‘)
????????????{
??????????????mima2[i]=mima[i];
??????????????break;
????????????}
????????}
??????while(strcmp(mimamima2)!=0)
????????{
??? ?????????printf(“?\n密碼輸錯了唉囧\n“);
??? ?????????printf(“請重新輸入密碼:“);
???
????????????????for(i=0;i<10;i++)
???????????????{
??? ?????????????????mima2[i]=getch();
?????????????????????putchar(‘*‘);
?????????????????????if(mima2[i]==‘\r‘)
???????????????????????{
???????????????????????? mima2[i]=mima[i];
????????????????????????????break;
????????????????????????}
???????????????}
?????????}
????printf(“\n請按以下格式輸入當日日期(例:20110831):“);
????scanf(“%ld“&date);
??????????????while(date<=20110901)
??????????????{
?????????????? printf(“\n你太忙了?...
- 上一篇:B樣條曲線繪制、bezier曲線繪制c語言實現
- 下一篇:用c語言求梯度的算法
評論
共有 條評論