c语言pos机怎么用,pos编程

用C语言模拟ATM机工作流程编程
#include “stdio.h”对ATM机器的模拟就是一个对队列的模拟下面代码在VC6环境下调试已经通过了其中有个缺陷就是因为代码执行速度过快导致二次执行根据时间随机出来的数字都是一样的因此你可以自己加上一个延迟子程序部分功能已经注释了#include “stdlib.h”#include “time.h”#defineOK 1#defineERROR 0
typedef struct node{ int number; struct node* next;}*Lnode;
typedef struct list{node *head,*rear;}Plist;
//模拟 ATM开业bool ListInit(Plist list){Lnode p; p = (Lnode)malloc(sizeof(Lnode)); list->head = p; list->rear = list->head; list->head->next = NULL; if(list->head!=NULL) return ERROR; else return OK;}
//模拟 有客户排队bool ListInsert(Plist list,int number){Lnode p;p = (Lnode)malloc(sizeof(Lnode));if(p==NULL) return ERROR;else{p->number= number;p->next= NULL;list->rear->next = p;list->rear = p;return OK; }}
//模拟 客户办完事离开bool ListDelete(Plist list){Lnode p;if(list->head ==list->rear)return ERROR;else{p= list->head->next;list->head->next = p->next;list->rear = list->head;//free(p);return OK;}}
void sand(int gettime,int* needtime){ srand(time(NULL)) ;*gettime= rand()%100; srand(time(NULL)) ;*needtime =rand()%100;}
//模拟客户到达事件void CustomerArrived(Plist list,int gettime,int needtime,int kehu,int time){int nextgettime,nextneedtime;sand(&nextgettime,&nextneedtime);while(needtime>0 && nextgettime>0 && time>0) {needtime–;nextgettime –;time; } if(nextgettime == 0 && needtime>0 &&time>0){kehu++;ListInsert(list,kehu);while(needtime>0 && time>0){needtime–;time–;}ListDelete(list);CustomerArrived(list,nextgettime,nextneedtime,kehu,time); } if(needtime ==0 && nextgettime>0 && time>0) {ListDelete(list);while(nextgettime>0 && time>0){nextgettime–;time;}kehu++;ListInsert(list,kehu);//未删除 ,list未传递进去CustomerArrived(list,nextgettime,nextneedtime,kehu,time); } if(time ==0) {printf(“ATM关门,请明天在来!\n”);return; }}
main(){list list; int i = 10000;//ATM机器每天工作时间 int kehu = 0;//客户标号 int gettime,needtime; ListInit(&list);//ATM开业 sand(&gettime,&needtime);ListInsert(&list,kehu);CustomerArrived(&list,gettime,needtime,kehu,i);getchar();
c语言中的 j=pos;pos++;什么作用
j=pos ====> 把pos的值赋值给j
pos++ ====> pos自加,,等同与pos=pos+1
C语言编程,模拟银行的ATM机
c语言ATM取款机怎么做 ,得输入密码的那种
#include
#include
#include
#include
#include
void sys(const char *ex)
printf(ex);
fflush(stdin);
getch();
struct atm
float money;
char card[20];
char pass[20];
};
struct atm *creat()
struct atm *p;
p=(struct atm *)malloc(sizeof(struct atm));
printf(“请输入密码:”);
gets(p->pass);getchar();
printf(“请输入卡号:”);
gets(p->card);getchar();
printf(“卡号为=%s,密码为=%s\n”,p->card,p->pass);
printf(“请输入预存款金额:”);
scanf(“%f”,&p->money);
return p;
struct atm *qukuan(struct atm *p)
printf(“请输入取款金额:”);
scanf(“%f”,&money);
if(money>p->money){printf(“余额不足!\n”);return p;}
p->money-=money;
void print(struct atm *p)
printf(“当前余额为%.2f,可取款金额为%d\n”,p->money,floor(p->money)/100);
int yanzheng(struct atm *p)
printf(“你好,请输入密码:”);
gets(pass);
if(strcmp(pass,p->pass)==0) return 1;
return 0;
void main()
int t=0;
p=creat();
do
t++;
while(!yanzheng(p)&&t<3);
if(t==3){printf(“密码连续三次输入错误,退出程序!\n”);return 1;}
while(1)
{
system(“cls”);
printf(“*欢迎您使用ATM取款机!*\n”);
printf(“1:\t取款\n”);
printf(“2:\t查看余额\n”);
printf(“0:\t退出\n”);
printf(“请选择:”);
scanf(“%d”,&t);
switch(t)
case 1:qukuan(p);break;
case 2:print(p);break;
if(!t)
sys(“请按任意键退出…”);
break;
sys(“请按任意键返回…”);
}