Ⅰ c語言用編程做一個餐廳叫號系統。包括用戶登錄,叫號,選桌(大小桌),統計(大小桌使用量,翻台率)
#include <stdio.h>
#include <stdlib.h>
char g_uniqueKey[24] = {0};
void ShowMainDlg()
{
system("cls");
printf("========XX餐廳======== ");
printf("1-取號 2-叫號 3-退號 4-退出系統 ");
printf("====================== ");
printf("請選擇對應菜單(1~4):");
}
void ShowAddDlg()
{
system("cls");
printf("========取號======== ");
printf("請輸入姓名 電話 用餐人數,按空格分隔 ");
printf("====================== ");
}
void ShowQueryDlg(char cName[], char cTel[], int iPeople)
(1)叫號取號系統c語言擴展閱讀:
餐廳桌號預訂系統基本功能:
1、餐廳提供小,中,大三種餐位,分別對應0~4人,5~8人,9人以上;
2、每種餐位若干,每個餐位都有相應的編號;
3、每種餐位使用收取的費用不同;
4、每位客人根據就餐人數選擇不同類型的餐位,系統則根據等待人數給用戶生成一個等待號碼,顯示客人當前排號以及在他之前有多少位客人在等待。
5、不同類型餐位都有自己的一個等待列,為客人生成的號碼互不影響;
6、支持查詢指定號碼所在的餐位。
Ⅱ C語言考試中 求求各位幫幫忙 謝謝
#include <stdio.h>
#include <stdlib.h>
#define ASK_OP(response) puts("INPUT O = IN Ordinary V = IN VIP Q = QUIT");response = getch();
typedef struct _cus{
int no;
char type;
int type_num;
struct _cus *next;
}customer;
int main(int argc, char *argv[])
{
customer * phead = NULL, *pcur = NULL, *ptail = NULL;
int i,j;
char ch;
ASK_OP(ch);
while(('Q' != ch) && ('q' != ch))
{
if('o' == ch || 'O' == ch)
{
if(NULL == phead)
{
if(NULL == (phead = (customer *)malloc(sizeof(customer))))return ;
phead->no = 1;
phead->type = 'o';
phead->type_num = 0;
phead->next = NULL;
pcur = phead;
}
else
{
i=0; //記錄類型為 Ordingary 的個數
ptail = phead;
while(!(NULL == ptail->next))
{
if(ptail->type == 'o') i = ptail->type_num;
ptail = ptail->next;
}
if(ptail->type == 'o') i = ptail->type_num;
if(NULL == (pcur = (customer *)malloc(sizeof(customer)))) return ;
ptail->next = pcur;
pcur->no = ptail->no+1;
pcur->type = 'o';
pcur->type_num = i+1;
pcur->next = NULL;
}
printf("\n%d Ordinary %d 前面有%d人等待\n",pcur->no,pcur->type_num,pcur->no-phead->no);
}
if('v' == ch || 'V' == ch)
{
if(NULL == phead)
{
if(NULL == (phead = (customer *)malloc(sizeof(customer)))) return ;
phead->no = 1;
phead->type = 'v';
phead->type_num = 0;
phead->next = NULL;
pcur = phead;
}
else
{
i=0; //記錄類型為 Vip 的個數
ptail = phead;
while(!(NULL == ptail->next))
{
if(ptail->type == 'v') i = ptail->type_num;
ptail = ptail->next;
}
if(ptail->type == 'v') i = ptail->type_num;
if(NULL == (pcur = (customer *)malloc(sizeof(customer)))) return ;
ptail->next = pcur;
pcur->no = ptail->no+1;
pcur->type = 'v';
pcur->type_num = i+1;
pcur->next = NULL;
}
printf("\n%d VIP %d 前面有%d人等待\n",pcur->no,pcur->type_num,pcur->no-phead->no);
}
ASK_OP(ch);
}
printf("\n GOOD bye");
system("PAUSE");
return 0;
}
Ⅲ 如何用簡單的c語言編寫銀行的排隊取號系統
可以用棧隊列來實現呀
Ⅳ C語言銀行排隊系統
你所指的隊列是線程嗎?
線程操作,大概思路如下:
1. 創建4個線程,表示四個窗口,用semaphore來等待客戶進入(WaitForSingleObject).
2. 創建n個線程表示客戶,每創建一個客戶增加一個ReleaseSemaphore,以讓窗口處理(記錄相關信息,隨機時間可以用srand獲取),窗口要設定為while循環,可以多次處理,條件可以設置為處理多少個客戶就可以退出.
3. 共用資源記得設置臨界區CriticalSection.
Ⅳ C#銀行排隊叫號系統
// 寫了一個比較簡陋的排隊系統,可以參考下:
classProgram{
staticvoidMain(string[]args){
ServiceWindow[]serviceWindows=newServiceWindow[Bank.MAX];
for(inti=0;i<Bank.MAX;i++)
serviceWindows[i]=newServiceWindow(){No=(i+1).ToString()};
Bankbank=newBank(serviceWindows);
Randomrand=newRandom();
//多線程模擬顧客取號
newThread(()=>{
intk=0;
while(true){
Bank.Enqueue();
if(++k>=100)break;
Thread.Sleep(1000);
}
}).Start();
//多線程模擬服務窗口叫號
newThread(()=>{
while(true){
bank.ServiceWindows[rand.Next(0,Bank.MAX)].Call();
Thread.Sleep(3000);
}
}).Start();
Console.ReadKey(true);
}
}
internalclassBank{
publicconstintMAX=3;
publicstaticConcurrentQueue<uint>queue{get;set;}
publicstaticvolatileuintcurNo=0;
publicBank(){
Init();
}
publicvoidInit()
{
queue=newConcurrentQueue<uint>();
}
publicBank(ServiceWindow[]serviceWindows)
{
Init();
ServiceWindows=serviceWindows;
}
publicServiceWindow[]ServiceWindows{get;set;}
publicstaticvoidEnqueue()
{
intk=0;
k=queue.Count();
curNo++;
queue.Enqueue(curNo);
Console.WriteLine("您的號碼是:"+(curNo)+",前面還有"+k+"人在等待!");
}
}
internalclassServiceWindow{
publicStringNo{get;set;}
publicboolCall()
{
uintresult=0;
boolsuccess=false;
success=Bank.queue.TryDequeue(outresult);
if(success)Console.WriteLine(result+"號,請到"+No+"號窗口辦理業務!");
returnsuccess;
}
}
Ⅵ 銀行排隊系統叫號,怎麼樣使各個窗口同時工作,c語言
設置一個標志,工作時置為1 然後while循環檢測時間, 到時間了就置為0,然後跳出while循環
調用窗口的時候先檢測該窗口的這個狀態,如果為1就接著檢測下個窗口,直到該窗口狀態為0,就為其服務
Ⅶ C語言問題 急
沒考慮輸入是否合法(例如客戶類型只能為Ordinary和VIP,退出用Quit),
時間關系湊合著用,按正確輸入的話能實現
#include "stdio.h"
#include "malloc.h"
#include "string.h"
#define null 0
struct List
{
char guesttype[10];
struct List *next;
}List;
struct List * InitList()
{
struct List *head,*p,*q;
head=(struct List *)malloc(sizeof(struct List));
head->next=null;
q=head;
int i;
bool star=true;
char c,InQuit[10],guest[10];
for (i=0;i<10&&(c=getchar())!='\n';i++)
{
if (c==' ')
{
star=false;
i=-1;
continue;
}
if (star)InQuit[i]=c;
else guest[i]=c;
}
guest[i]='\0';
while(InQuit[0]=='I'&&InQuit[1]=='N')
{
p=(struct List *)malloc(sizeof(struct List));
p->next=null;
strcpy(p->guesttype,guest);
q->next=p;
q=p;
star=true;
for (i=0;i<10&&(c=getchar())!='\n';i++)
{
if (c==' ')
{
star=false;
i=-1;
continue;
}
if (star)InQuit[i]=c;
else guest[i]=c;
}
}
return head;
}
void print(struct List *head)
{
struct List *p;
int num=0;
if(head)
{
p=head->next;
while(p)
{
printf("IN:\n");
printf("%d %s %d\n",num+1,p->guesttype,num);
p=p->next;
num++;
}
printf("GOOD BYE!\n");
}
}
void main()
{
struct List *head;
head=InitList();
print(head);
}
Ⅷ 簡單的銀行叫號系統 C++編程
編程是好比是兩個城市之間的旅程,開發語言(C++)就好比是交通工具,其實乘坐什麼工具並不重要,最重要的是你要知道怎麼走,也就是整個程序的設計你要明了。廢話少說,下面簡單介紹一下這個系統的開發流程:
第一步,先把資料庫設計好,如果是單個銀行網點,可以用ACCESS或者sqllite資料庫,如果是某個銀行集團的多個網點,那就需考慮用大型資料庫了,比如Microsoft SQL Server;
資料庫中最起碼要包含以下幾個表:
1,業務類型表:
2,取號類型表(普通號、優先號)
3,掛號表等
第二步,搭系統框架,這個是整個程序的基石,如果如果要自己設計的話,首先你要有兩三年的編程經驗,急不得。你可以去網上或者是學長那找一些好的模板,這樣會快一點。
4,畫界面
整個程序的界麵包含主界面和一些基本數據的維護界面以及統計報表等,這個需要你一步一步去畫。
5,基本的增刪改查資料庫操作
界面畫好之後,就要對基本數據進行處理了,程序的許多BUG也會在這個時候產生,這個也是基本功,祝你好運。
6,數據的增刪改查做完之後整個程序的開發也就完成的差不多了,剩下的就是一下細節性的東西,不過此時你的旅途只完成了一半。
7,還有一半的工作就是測試測試再測試
若還有疑問,咨詢HESIN排隊。網路HESIN排隊就可以。
Ⅸ 用C語言編銀行叫號系統
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <conio.h>
#define MAX_SIZE 500
struct tagCustom
{
int m_nID; // 客戶的編號
int m_nProcessTime; // 需要處理業務的時間
int m_nArrivalTime; // 到達時間
int m_nDepartTime; // 離開時間
};
struct tagTeller
{
int m_nCustomNum; // 處理的客戶數
int m_nAllServiceTime; // 所有服務時間
int m_nFinishServiceTime; // 櫃台針對一個客戶服務的結束時間
bool m_bBusy; // 櫃台是否忙
int m_nCustomID; // 正在服務的客戶的ID號
};
tagTeller g_aryTellers[MAX_SIZE];
int g_nTellerNum; // 櫃台數量
// 用戶到達數組(隨機的,無序的)
tagCustom g_aryAllCustoms[MAX_SIZE];
int g_nCustomsNum;
int g_nWorkTime; // 經營時間
int g_nArrivalRange,g_nServiceRange;
// 用戶隊列
tagCustom g_CustomQueue[MAX_SIZE];
int g_nHeader,g_nTail;
// 隊列的操作
void InitQueue()
{
g_nHeader = g_nTail = -1;
}
void AddToTail(tagCustom aCustom)
{
g_nTail++;
g_CustomQueue[g_nTail] = aCustom;
}
bool RemoveFromHeader(tagCustom* pCustom)
{
if(g_nHeader < g_nTail)
{
g_nHeader++;
(*pCustom) = g_CustomQueue[g_nHeader];
return true;
}
return false;
}
// 功能:模擬用戶的隨機到來
void GenerateCustom()
{
tagCustom aCustom;
for(int nCounter = 0; nCounter < g_nCustomsNum; nCounter++)
{
aCustom.m_nID = nCounter;
aCustom.m_nArrivalTime = rand() % g_nWorkTime ;
aCustom.m_nProcessTime = (rand() % g_nServiceRange + 1) * 6;
aCustom.m_nDepartTime = -1;
g_aryAllCustoms[nCounter] = aCustom;
}
}
void Init()
{
g_nTellerNum = 3;
g_nWorkTime = 200;
g_nCustomsNum = 30;
g_nArrivalRange = 18 ;
g_nServiceRange = 5 ;
srand((unsigned)time(NULL));
InitQueue();
GenerateCustom();
for(int nC = 0; nC < g_nTellerNum; nC++)
{
g_aryTellers[nC].m_nAllServiceTime = 0;
g_aryTellers[nC].m_nCustomID = -1;
g_aryTellers[nC].m_bBusy = false;
g_aryTellers[nC].m_nFinishServiceTime = -1;
}
}