當前位置:首頁 » 編程語言 » c語言課程設計旅店登記系統
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言課程設計旅店登記系統

發布時間: 2022-09-13 01:41:57

A. 急!急!尋求一個c語言課程設計(學籍管理系統)

#include <stdio.h>
#include <stdlib.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{long num;
char sex;
int age;
float score[3];
char name[20];
struct student *next;
};
int n;
struct student *creat(void)
{struct student * head;
struct student * p1,* p2;
n=0;
p1=p2=(struct student * )malloc(LEN);
scanf("%ld,%c,%d,%f,%f,%f,%s",&p1->num,&p1->sex,&p1->age,&p1->score[0],&p1->score[1],&p1->score[2],p1->name);
head=p1;
while(p1->num!=0)
{n=n+1;
if(n!=1)
p2->next=p1;
p2=p1;
p1=(struct student * )malloc(LEN);
scanf("%ld,%c,%d,%f,%f,%f,%s",&p1->num,&p1->sex,&p1->age,&p1->score[0],&p1->score[1],&p1->score[2],p1->name);
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{struct student * p1;
printf("\nNow,There %d records are :\n",n);
p1=head;
while(p1!=NULL)
{printf("%ld,%c,%d,%f,%f,%f,%s\n",p1->num,p1->sex,p1->age,p1->score[0],p1->score[1],p1->score[2],p1->name);
p1=p1->next;
}
}
struct student * del(struct student *head,int age)
{struct student * p1,* p2,*p3;int a=n;
if(head==NULL) {printf("\nlist null! \n");goto end;}
p1=head;
loop:while(age!= p1->age&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(age==p1->age)
{if(p1==head)head=p1->next;
else p2->next=p1->next;
printf("delete:%d\n",age);
n=n-1;p3=p1;
p1=p1->next;free(p3);
goto loop;
}
else if(n==a) printf("%d not beed found!\n",age);
end:;
return (head);
}
struct student * insert(struct student * head,struct student *stud)
{struct student * p0,* p1,* p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->num>p1->num)&&(p1->next!=NULL))
{p2=p1;
p1=p1->next;}
if(p0->num<=p1->num)
{if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;}
else
{p1->next=p0;p0->next=NULL;}
}
n=n+1;
return(head);
}

void main()
{struct student *head,* stu;
int del_age;
printf("input records:\n");
head=creat();
print(head);
printf("\ninput the deleted age:");
scanf("%d",&del_age);
while(del_age!=0)
{head=del(head,del_age);
print(head);
printf("\ninput the deleted age:");
scanf("%d",&del_age);}
printf("\ninput the inserted record:");
stu=(struct student * )malloc(LEN);
scanf("%ld,%c,%d,%f,%f,%f,%s",&stu->num,&stu->sex,&stu->age,&stu->score[0],&stu->score[1],&stu->score[2],stu->name);
while(stu->num!=0)
{head=insert(head,stu);
print(head);
printf("\ninput the inserted record:");
stu=(struct student * )malloc(LEN);
scanf("%ld,%c,%d,%f,%f,%f,%s",&stu->num,&stu->sex,&stu->age,&stu->score[0],&stu->score[1],&stu->score[2],stu->name); }
}

B. C語言課程設計

/******頭文件(.h)***********/
#include "stdio.h" /*I/O函數*/
#include "stdlib.h" /*標准庫函數*/
#include "string.h"/*字元串函數*/
#include "ctype.h" /*字元操作函數*/
#include "conio.h" /*控制台輸入輸出函數 */
#define M 50 /*定義常數表示記錄數*/
typedef struct /*定義數據結構*/
{
char name[20]; /*姓名*/
char units[30]; /*單位*/
char tele[20]; /*電話*/
char m_ph[20]; //手機
char rela[20]; //關系
char email[50]; //郵箱
char qq[20]; //qq
}ADDRESS;
/******以下是函數原型*******/
int enter(ADDRESS t[]); /*輸入記錄*/
void list(ADDRESS t[],int n); /*顯示記錄*/
void search(ADDRESS t[],int n); /*按姓名查找顯示記錄*/
int Delete(ADDRESS t[],int n); /*刪除記錄*/
int add(ADDRESS t[],int n); /*插入記錄*/
void save(ADDRESS t[],int n); /*記錄保存為文件*/
int load(ADDRESS t[]); /*從文件中讀記錄*/
void display(ADDRESS t[]); /*按序號查找顯示記錄*/
void sort(ADDRESS t[],int n); /*按姓名排序*/
void qseek(ADDRESS t[],int n); /*快速查找記錄*/
void print(ADDRESS temp); /*顯示單條記錄*/
int find(ADDRESS t[],int n,char *s) ; /*查找函數*/
int menu_select(); /*主菜單函數*/
/******主函數開始*******/
main()
{
system("color 37");//背景色為淺綠,前景色為白色
printf(" 歡迎使用通訊錄管理系統\n");//歡迎界面
int i;
ADDRESS adr[M]; /*定義結構體數組*/
int length; /*保存記錄長度*/
for(;;)/*無限循環*/
{
switch(menu_select()) /*調用主菜單函數,返回值整數作開關語句的條件*/
{
case 0:length=enter(adr);break;/*輸入記錄*/
case 1:list(adr,length);break; /*顯示全部記錄*/
case 2:search(adr,length);break; /*查找記錄*/
case 3:length=Delete(adr,length);break; /*刪除記錄*/
case 4:length=add(adr,length); break; /*插入記錄*/
case 5:save(adr,length);break; /*保存文件*/
case 6:length=load(adr); break; /*讀文件*/
case 7:display(adr);break; /*按序號顯示記錄*/
case 8:sort(adr,length);break; /*按姓名排序*/
case 9:qseek(adr,length);break; /*快速查找記錄*/
case 10:exit(0); /*如返回值為10則程序結束*/
}
}
}
/*菜單函數,函數返回值為整數,代表所選的菜單項*/
int menu_select()
{
char s[80];
int c;
printf("按任意鍵進入菜單......\n");/*提示按任意鍵繼續*/
getch(); /*讀入任意字元*/
system("cls"); /*清屏*/
printf(" ********************菜單***********************\n\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(" 8. 記錄排序\n");
printf(" 9. 查找記錄\n");
printf(" 10. 退出\n");
printf(" ***********************************************\n");
do
{
printf("\n 請輸入選項(0~10):"); /*提示輸入選項*/
scanf("%d",&c);/*輸入選擇項*/
fflush(stdin);
}while(c<0 || c>10);/*選擇項不在0~10之間重輸*/
return c; /*返回選擇項,主程序根據該數調用相應的函數*/
}
/***輸入記錄,形參為結構體數組,函數值返回類型為整型表示記錄長度*/
int enter(ADDRESS t[])
{
int i,n;
char num[30];
system("cls"); /*清屏*/
int flag=1;
for(;;)
{
flag = 1;
system("cls"); /*清屏*/
printf("\n請輸入記錄數:\n"); /*提示信息*/
scanf("%s", &num); /*輸入記錄數*/
fflush(stdin);
for(int nima = 0; num[nima]; nima++)
{
if (num[nima] < 48 || num[nima] > 57)
{
flag = 0;
break;
}
}
if(flag==1)
break;
}
n=atoi(num);
printf("請輸入記錄:\n"); /*提示輸入記錄*/
printf("姓名 單位 電話 手機 關系 郵箱 QQ\n");
printf("--------------------------------------------------------------------------\n");
for(i=0;i<n;i++)
{
scanf("%s%s%s%s%s%s%s",t[i].name,t[i].units,t[i].tele,t[i].m_ph,t[i].rela,t[i].email,t[i].qq); /*輸入記錄*/
fflush(stdin);
for(int k=0;k<=19;k++)
{
if((t[i].tele[k]>='a' && t[i].tele[k]<='z' )|| (t[i].tele[k]>='A' && t[i].tele[k]<='Z'))
{
printf("電話輸入錯誤!請重新輸入聯系人信息\n");
i--;
break;
}
if((t[i].m_ph[k]>='a' && t[i].m_ph[k]<='z' )|| (t[i].m_ph[k]>='A' && t[i].m_ph[k]<='Z'))
{
printf("手機輸入錯誤!請重新輸入聯系人信息\n");
i--;
break;
}
if((t[i].qq[k]>='a' && t[i].qq[k]<='z' )|| (t[i].qq[k]>='A' && t[i].qq[k]<='Z'))
{
printf("QQ輸入錯誤!請重新輸入聯系人信息\n");
i--;
break;
}
}
printf("--------------------------------------------------------------------------\n");
}
return n; /*返回記錄條數*/
}
/*顯示記錄,參數為記錄數組和記錄條數*/
void list(ADDRESS t[],int n)
{
int i;
system("cls"); /*清屏*/
printf("\n\n************************************************************************\n");
printf("姓名 單位 電話 手機 關系 郵箱 QQ\n");
printf("--------------------------------------------------------------------------\n");
for(i=0;i<n;i++)
printf("%-10s%-14s%-12s%-12s%-10s%-12s%-14s\n",t[i].name,t[i].units,t[i].tele,t[i].m_ph,t[i].rela,t[i].email,t[i].qq);
if((i+1)%10==0) /*判斷輸出是否達到10條記錄*/
{
printf("按任意鍵顯示下一頁\n"); /*提示信息*/
getch(); /*按任意鍵繼續*/

}
printf("*********************************結束***********************************\n");
}
/*查找記錄*/
void search(ADDRESS t[],int n)
{
char s[20]; /*保存待查找姓名字元串*/
int i; /*保存查找到結點的序號*/
system("cls"); /*清屏*/
printf("請輸入待查找姓名:\n");
scanf("%s",s); /*輸入待查找姓名*/
i=find(t,n,s); /*調用find函數,得到一個整數*/
if(i>n-1) /*如果整數i值大於n-1,說明沒找到*/
{
printf("未找到!!!\n");
getch();
}
else
print(t[i]); /*找到,調用顯示函數顯示記錄*/
}
/*顯示指定的一條記錄*/
void print(ADDRESS temp)
{
system("cls"); /*清屏*/
printf("\n\n************************************************************************\n");
printf("姓名 單位 電話 手機 關系 郵箱 QQ\n");
printf("--------------------------------------------------------------------------\n");
printf("%-10s%-14s%-12s%-12s%-10s%-12s%-14s\n",temp.name,temp.units,temp.tele,temp.m_ph,temp.rela,temp.email,temp.qq);
printf("*********************************結束***********************************\n");
getchar();
}
/*查找函數,參數為記錄數組和記錄條數以及姓名s */
int find(ADDRESS t[],int n,char *s)
{
int i;
system("cls"); /*清屏*/
for(i=0;i<n;i++)/*從第一條記錄開始,直到最後一條*/
{
if(strcmp(s,t[i].name)==0) /*記錄中的姓名和待比較的姓名是否相等*/
return i; /*相等,則返回該記錄的下標號,程序提前結結束*/
}
return i; /*返回i值*/
getch();
}
/*刪除函數,參數為記錄數組和記錄條數*/
int Delete(ADDRESS t[],int n)
{
char s[20]; /*要刪除記錄的姓名*/
char ch;
int i,j;
system("cls"); /*清屏*/
printf("請輸入待刪除的姓名:\n"); /*提示信息*/
scanf("%s",s);/*輸入姓名*/
i=find(t,n,s); /*調用find函數*/
if(i>n-1) /*如果i>n-1超過了數組的長度*/
printf("未找到!!!\n"); /*顯示沒找到要刪除的記錄*/
else
{
print(t[i]); /*調用輸出函數顯示該條記錄信息*/
printf("確定刪除?(Y/N)\n"); /*確認是否要刪除*/
scanf("%c",&ch); /*輸入一個整數0或1*/
if(ch=='y' || ch=='Y') /*如果確認刪除輸入y*/
{
for(j=i+1;j<n;j++) /*刪除該記錄,實際後續記錄前移*/
{
strcpy(t[j-1].name,t[j].name); /*將後一條記錄的姓名拷貝到前一條*/
strcpy(t[j-1].units,t[j].units); /*將後一條記錄的單位拷貝到前一條*/
strcpy(t[j-1].tele,t[j].tele); /*將後一條記錄的電話拷貝到前一條*/
strcpy(t[j-1].m_ph,t[j].m_ph); /*將後一條記錄的手機拷貝到前一條*/
strcpy(t[j-1].rela,t[j].rela); /*將後一條記錄的關系拷貝到前一條*/
strcpy(t[j-1].email,t[j].email); /*將後一條記錄的郵箱拷貝到前一條*/
strcpy(t[j-1].qq,t[j].qq); /*將後一條記錄的qq拷貝到前一條*/
}
printf("刪除成功!\n");
n--; /*記錄數減1*/
}
}
getch();
return n; /*返回記錄數*/
}
/*插入記錄函數,參數為結構體數組和記錄數*/
int add(ADDRESS t[],int n)/*插入函數,參數為結構體數組和記錄數*/
{
ADDRESS temp; /*新插入記錄信息*/
int i,j,flag;
char s[30]; /*確定插入在哪個記錄之前*/
system("cls"); /*清屏*/
printf("請輸入記錄:\n");
printf("************************************************************************\n");
printf("姓名 單位 電話 手機 關系 郵箱 QQ\n");
printf("--------------------------------------------------------------------------\n");
scanf("%s%s%s%s%s%s%s",temp.name,temp.units,temp.tele,temp.m_ph,temp.rela,temp.email,temp.qq); /*輸入插入信息*/
fflush(stdin);
printf("請輸入插入位置的姓名: \n");
scanf("%s",s); /*輸入插入位置的姓名*/
i=find(t,n,s); /*調用find,確定插入位置*/
for(j=n-1;j>=i;j--) /*從最後一個結點開始向後移動一條*/
{
strcpy(t[j+1].name,t[j].name); /*當前記錄的姓名拷貝到後一條*/
strcpy(t[j+1].units,t[j].units); /*當前記錄的單位拷貝到後一條*/
strcpy(t[j+1].tele,t[j].tele); /*當前記錄的電話拷貝到後一條*/
strcpy(t[j+1].m_ph,t[j].m_ph); /*當前記錄的手機拷貝到後一條*/
strcpy(t[j+1].rela,t[j].rela); /*當前記錄的關系拷貝到後一條*/
strcpy(t[j+1].email,t[j].email); /*當前記錄的郵箱拷貝到後一條*/
strcpy(t[j+1].qq,t[j].qq); /*當前記錄的qq拷貝到後一條*/
}
strcpy(t[i].name,temp.name); /*將新插入記錄的姓名拷貝到第i個位置*/
strcpy(t[i].units,temp.units); /*將新插入記錄的單位拷貝到第i個位置*/
strcpy(t[i].tele,temp.tele); /*將新插入記錄的電話拷貝到第i個位置*/
strcpy(t[i].m_ph,temp.m_ph); /*將新插入記錄的手機拷貝到第i個位置*/
strcpy(t[i].rela,temp.rela); /*將新插入記錄的關系拷貝到第i個位置*/
strcpy(t[i].email,temp.email); /*將新插入記錄的郵箱拷貝到第i個位置*/
strcpy(t[i].qq,temp.qq); /*將新插入記錄的qq拷貝到第i個位置*/
n++; /*記錄數加1*/
printf("添加成功!!!\n");
getch();
return n; /*返回記錄數*/
}
/*保存函數,參數為結構體數組和記錄數*/
void save(ADDRESS t[],int n)
{
int i;
char outfile[30];
FILE *fp; /*指向文件的指針*/
system("cls"); /*清屏*/
printf("請輸入待保存的文件名:\n");
scanf("%s",outfile);
if((fp=fopen(outfile,"wb"))==NULL) /*打開文件,並判斷打開是否正常*/
{
printf("無法打開文件!\n");/*無法打開*/
exit(1); /*退出*/
}
printf("\n保存文件...\n"); /*輸出提示信息*/
fprintf(fp,"%d",n); /*將記錄數寫入文件*/
fprintf(fp,"\r\n"); /*將換行符號寫入文件*/
for(i=0;i<n;i++)
{
fprintf(fp,"%-10s%-14s%-12s%-12s%-10s%-12s%-14s\n",t[i].name,t[i].units,t[i].tele,t[i].m_ph,t[i].rela,t[i].email,t[i].qq);/*格式寫入記錄*/
fprintf(fp,"\r\n"); /*將換行符號寫入文件*/
}
fclose(fp);/*關閉文件*/
printf("****保存成功!****\n"); /*顯示保存成功*/
getch();
}
/*載入函數,參數為結構體數組*/
int load(ADDRESS t[])
{
int i,n;
char outfile[30];
FILE *fp; /*指向文件的指針*/
system("cls"); /*清屏*/
printf("請輸入待載入的文件名:\n");
scanf("%s",outfile);
if((fp=fopen(outfile,"rb"))==NULL)/*打開文件*/
{
printf("無法打開文件!\n"); /*不能打開*/
exit(1); /*退出*/
}
fscanf(fp,"%d",&n); /*讀入記錄數*/
for(i=0;i<n;i++)
fscanf(fp,"%10s%14s%12s%12s%10s%12s%14s",t[i].name,t[i].units,t[i].tele,
t[i].m_ph,t[i].rela,t[i].email,t[i].qq); /*按格式讀入記錄*/
fclose(fp); /*關閉文件*/
printf("從文件讀入數據成功!!!\n"); /*顯示保存成功*/
getch();
return n; /*返回記錄數*/

}
/*按序號顯示記錄函數*/
void display(ADDRESS t[])
{
int id,n;
char outfile[30];
FILE *fp; /*指向文件的指針*/
system("cls"); /*清屏*/
printf("請輸入待載入的文件名:");
scanf("%s",outfile);
if((fp=fopen(outfile,"rb"))==NULL) /*打開文件*/
{
printf("無法打開文件!\n"); /*不能打開文件*/
exit(1); /*退出*/
}
printf("請輸入記錄序號:\n"); /*顯示信息*/
scanf("%d",&id); /*輸入序號*/
fscanf(fp,"%d",&n); /*從文件讀入記錄數*/
if(id>=0&&id<n) /*判斷序號是否在記錄范圍內*/
{
fseek(fp,(id-1)*sizeof(ADDRESS),1); /*移動文件指針到該記錄位置*/
print(t[id]); /*調用輸出函數顯示該記錄*/
printf("\r\n");
}
else
{
printf(" %d號記錄不存在!!!\n ",id); /*如果序號不合理顯示信息*/
getch();
}
fclose(fp); /*關閉文件*/
}
/*排序函數,參數為結構體數組和記錄數*/
void sort(ADDRESS t[],int n)
{
int i,j,flag;
system("cls"); /*清屏*/
ADDRESS temp; /*臨時變數做交換數據用*/
for(i=0;i<n;i++)
{
flag=0; /*設標志判斷是否發生過交換*/
for(j=0;j<n-1;j++)
if((strcmp(t[j].name,t[j+1].name))>0) /*比較大小*/
{
flag=1;
strcpy(temp.name,t[j].name); /*交換記錄*/
strcpy(temp.units,t[j].units);
strcpy(temp.tele,t[j].tele);
strcpy(temp.m_ph,t[j].m_ph);
strcpy(temp.rela,t[j].rela);
strcpy(temp.email,t[j].email);
strcpy(temp.qq,t[j].qq);

strcpy(t[j].name,t[j+1].name);
strcpy(t[j].units,t[j+1].units);
strcpy(t[j].tele,t[j+1].tele);
strcpy(t[j].m_ph,t[j+1].m_ph);
strcpy(t[j].rela,t[j+1].rela);
strcpy(t[j].email,t[j+1].email);
strcpy(t[j].qq,t[j+1].qq);

strcpy(t[j+1].name,temp.name);
strcpy(t[j+1].units,temp.units);
strcpy(t[j+1].tele,temp.tele);
strcpy(t[j+1].m_ph,temp.m_ph);
strcpy(t[j+1].rela,temp.rela);
strcpy(t[j+1].email,temp.email);
strcpy(t[j+1].qq,temp.qq);
}
if(flag==0)break; /*如果標志為0,說明沒有發生過交換循環結束*/
}
printf("排序成功!!!\n"); /*顯示排序成功*/
}
/*快速查找,參數為結構體數組和記錄數*/
void qseek(ADDRESS t[],int n)
{
char s[20];
int l,r,m;
system("cls"); /*清屏*/
printf("\n請在查找前排序!\n"); /*提示確認在查找之前,記錄是否已排序*/
printf("請輸入待查找的姓名:\n"); /*提示輸入*/
scanf("%s",s); /*輸入待查找的姓名*/
l=0;r=n-1; /*設置左邊界與右邊界的初值*/
while(l<=r) /*當左邊界<=右邊界時*/
{
m=(l+r)/2; /*計算中間位置*/
if(strcmp(t[m].name,s)==0) /*與中間結點姓名欄位做比較判是否相等*/
{
print(t[m]); /*如果相等,則調用print函數顯示記錄信息*/
return ; /*返回*/
}
if(strcmp(t[m].name,s)<0) /*如果中間結點小*/
l=m+1; /*修改左邊界*/
else
r=m-1; /*否則,中間結點大,修改右邊界*/
}
if(l>r) /*如果左邊界大於右邊界時*/
printf("未找到!\n"); /*顯示沒找到*/
getch();
}

C. C語言實現酒店信息管理系統

不知道你的要求是什麼,把我以前的關於酒店管理的代碼發給你參考下吧。

#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
typedefstructtagCustomer
{
charm_ID[19];/*身份證號碼*/
charm_name[10];/*顧客姓名*/
intm_age;/*顧客年齡*/
charm_sex[6];/*顧客性別*/
intnum;
}Customer;/*顧客結構*/

typedefstructtagRoom
{
intm_num;/*房間號*/
intm_floor;/*樓層*/
intm_price;/*價格*/
intm_use;/*是否已入住*/
}Room;/*房間結構*/
inti,j=0,age,num,floor,price,use,n;
intreg=0;
Customercus[5];
Roomr[5];
intcount=5;
charID[18],name[10],sex[6];
FILE*fproom;
FILE*fpcustomer;

voidCustomer_Input()
{
if(count<=5)
{
printf("請輸入身份證號(18位數字):");
scanf("%s",&cus[j].m_ID);
printf("請輸入姓名(10位字元)");
scanf("%s",&cus[j].m_name);
printf("請輸入年齡(數字型)");
scanf("%d",&cus[j].m_age);
printf("請輸入性別(男或女):");
scanf("%s",&cus[j].m_sex);
}
else
{
printf(" 存儲空間已滿!");
}
printf(" 顧客可以住在:");
printf(" 房間號樓層價格是否空閑(1:空閑0:已使用)");
for(i=0;i<count;i++)
{
if(r[i].m_use==1)
{
printf(" %d%d%d%d",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);
}
}
printf(" 請你輸入房間號:");
scanf("%d",&num);
reg=0;
for(i=0;i<count;i++)
{
if(r[i].m_use==1&&r[i].m_num==num)
{
r[i].m_use=0;
printf(" 登記成功! ");
cus[j].num=r[i].m_num;
j=j+1;
reg=1;
}
}
if(reg==0)
{
printf(" 登記失敗! ");
}

}
voidCustomer_ListOut()
{
if(count<=5)
{
printf("請輸入身份證號(18位數字):");
scanf("%s",&ID);
for(i=0;i<count;i++)
{
if(strcmp(cus[i].m_ID,ID)==0)
{
printf(" 顧客身份證號:%s姓名:%s年齡:%d性別:%s ",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);
}
}
}
else
{
printf(" ");
}
}
voidRoom_ListOut()
{
printf(" 房間號樓層價格是否空閑(1:空閑0:已使用)");
for(i=0;i<count;i++)
{
if(r[i].m_use==1)
{
printf(" %d%d%d%d",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);
}
}
}
voidPerCustomer_Search()
{
if(count<=5)
{
printf("請輸入身份證號(18位數字):");
scanf("%s",&cus[j].m_ID);
printf("請輸入姓名(10位字元)");
scanf("%s",&cus[j].m_name);
printf("請輸入年齡(數字型)");
scanf("%d",&cus[j].m_age);
printf("請輸入性別(男或女):");
scanf("%s",&cus[j].m_sex);
}
else
{
printf(" 住房已滿!");
}
printf(" 顧客可以預訂:");
printf(" 房間號樓層價格是否空閑(1:空閑0:已使用)");
for(i=0;i<count;i++)
{
if(r[i].m_use==1)
{
printf(" %d%d%d%d",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);
}
}
printf(" 請你輸入要預訂的房間號:");
scanf("%d",&num);
reg=0;
for(i=0;i<count;i++)
{
if(r[i].m_use==1&&r[i].m_num==num)
{
r[i].m_use=0;
printf(" 預訂成功! ");
cus[j].num=r[i].m_num;
j=j+1;
reg=1;
}
}
if(reg==0)
{
printf(" 預訂失敗! ");
}
}
voidUnCustomer_Out()
{
intk;
printf(" 請輸入要退房顧客身份證:");
scanf("%s",&ID);
for(i=0;i<count;i++)
{
if(strcmp(cus[i].m_ID,ID)==0)
{
printf(" 顧客身份證號:%s姓名:%s年齡:%d性別:%s 已經成功退房!",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);
for(k=0;k<count;k++)
if(r[k].m_num==cus[i].num)
r[k].m_use=1;
memset(&cus[i],0,sizeof(Customer));

}
}
}
voidCustomer_Goaway()
{
fproom=fopen("room","wb+");
fwrite((void*)&r,sizeof(Room),count,fproom);
fclose(fproom);

fpcustomer=fopen("customer","wb+");
fwrite((void*)&r,sizeof(Room),count,fpcustomer);
fclose(fpcustomer);
exit(0);

}
main()
{
fproom=fopen("room","wb");
if(fproom!=NULL)
{
for(i=0;i<count;i++)
{
intid=100;
r[i].m_num=i+100;
r[i].m_floor=1;
r[i].m_price=100;
r[i].m_use=1;
}
fwrite((void*)&r,sizeof(Room),count,fproom);
fclose(fproom);
}
else
{
printf(" ---文件打開失敗--");
}
for(;;)
{

printf(" ");
printf("/******************************************\ ");
printf("** ");
printf("*酒店管理系統* ");
printf("*主菜單* ");
printf("** ");
printf("*1.顧客登記* ");
printf("*2.查詢顧客信息* ");
printf("*3.查詢空房間* ");
printf("*4.預訂房間* ");
printf("*5.退訂房間* ");
printf("*6.保存並退出系統* ");
printf("** ");
printf("\******************************************/ ");
printf("請輸入選擇項(1-6):");
scanf("%d",&n);
printf(" ");
if(n>0&&n<=6)
{
switch(n)
{
case1:Customer_Input();break;
case2:Customer_ListOut();break;/*查詢顧客信息*/
case3:Room_ListOut();break;/*查詢空房間*/
case4:PerCustomer_Search();break;/*預訂房間*/
case5:UnCustomer_Out();break;/*退訂房間*/
case6:Customer_Goaway();/*保存退出*/
}
}
else
{
printf("*********************************************************************** ");
printf("** ");
printf("*輸入錯誤!* ");
printf("*請退出!* ");
printf("** ");
printf("*********************************************************************** ");
break;
}
}
}

D. 求一個C語言程序段可以在酒店客房管理系統中實現計時的功能,謝謝啦!

這。。 太簡單了。。
cus 的結構體,增加 日期時間 描述。。。 如:struct tm inDateTime;
struct tm {//time.h 頭文件中結構定義
int tm_sec; /* Seconds */
int tm_min; /* Minutes */
int tm_hour; /* Hour (0 - 23) */
int tm_mday; /* Day of month (1 - 31) */
int tm_mon; /* Month (0 - 11) */
int tm_year; /* Year (calendar year minus 1900) */
int tm_wday; /* Weekday (0 - 6; Sunday is 0) */
int tm_yday; /* Day of year (0 -365) */
int tm_isdst; /* Nonzero if daylight saving time is in effect. */
};
struct tm *gmtime(const time_t *timer);//相關函數,獲取當前時間

gettime(&cus.inDateTime);

printf("\n\r顧客可以住在:"); 的上面加入代碼:gettime(&cus.inDateTime); 保存信息的時候,記錄保存信息時的時間。

結算的時候。。。 再用 gettime(tmpCurDateTime);
然後自己在 tmpCurDateTime 和 cus.inDateTime 做加減法。。。

相關定義在 time.h 中

E. c語言課程設計 賓館客房管理軟體

1)某賓館有301.302.303.304.305五個標准間,每個標准間可住2人;
2)鏈表儲存結構: 姓名,性別,房號。後續指針,按房間號有序:
3)能實現入住和退房,能按給定姓名房號查詢;
4)建議採用連表結構,但用其他事先也可
各位幫幫忙 急用 一定要用C語言啊 不是c++啊

F. c語言酒店管理系統

20分?我倒
給個建構你,至於怎麼實現自己想辦法了
struct Hotel
{
int index;//客房編號;
int type;//客房類型;
int position;//客房位置;
int area;//面積;
int bedsOfRoom;//床位數;
int price;//價格
Hotel*next;
};

G. c語言設計 旅行社管理系統

去買一套系統吧

H. c語言課程設計宿舍管理系統,我寫的老有錯誤,請大神幫忙修改一下,好的加分

#include<stdio.h>
#include<string.h>
#define MaxSize 6
struct student_info
{ char name[8];
int sum;
char intime;
char outime;
int number;
int studentroom;
}StudentList[MaxSize];
int Insert(int*a);
void Update(int);//這少了個分號
void Delete(int*a);
int main()
{int i;
int count=0;
do
{printf("\n");
printf("1.插入(Insert)\n");
printf("2.修改(Update)\n");
printf("3.刪除(Delete)\n");
printf("4.退出(Eixt)\n");
scanf("%d",&i);
switch(i)
{case 1:Insert(&count);break;
case 2:Update(count);break;
case 3:Delete(&count);break;
case 4:break;
default:printf("輸入錯誤,請重新輸入!");break;}
}
while(i!=6);
return 0;
}
int Insert(int*count)
{
int i,in_number;
if(*count==MaxSize)
{printf("空間已滿!");
return 0;}
printf("請輸入編號:");
scanf("%d",&in_number);
for(i=0;i<*count;i++)
if(StudentList[i].number==in_number)
{printf("已經有相同的編號:"); //這的分號是中文符號
return 0;}//return沒有返回值
StudentList[i].number=in_number;//應該是.number你打成了,number
printf("請輸入學生姓名:");
scanf("%s",StudentList[i].name);//看到這我覺得你的程序是的吧,以前是個Guest。。。。。
printf("請輸入學號:");
scanf("%d",StudentList[i].number);//
printf("請輸入房間號:");
scanf("%d",StudentList[i].studentroom);
printf("請輸入入住日期:");
scanf("%s",StudentList[i].intime);
printf("請輸入離開日期:");
scanf("%s",StudentList[i].outime); //這里outime打錯了!
(*count)++;
return 0;
}
void Search(int count)
{int i,number,flag=1;
printf("請輸入要查詢的編號:");
scanf("%d",&number);
for(i=0;i<count&&flag;i++)
if(StudentList[i].number==number)
{printf("姓名:%s",StudentList[i].name);
printf("學號:%d",StudentList[i].number);
printf("房間號:%d",StudentList[i].studentroom);
printf("入住日期:%s",StudentList[i].intime);
printf("離開日期:%s",StudentList[i].outime);
flag=0;}
else
printf("沒有查詢到!");}//這里少了個分號
void Update(int count)
{ int i,number,flag=1;
printf("請輸入要修改數據的編號:");
scanf("%d",&number);
for(i=0;i,count&&flag;i++)
if(StudentList[i].number==number)
{printf("請輸入學生姓名:");
scanf("%s",StudentList[i].name);
printf("請輸入學號:");
scanf("%d",StudentList[i].number);
printf("請輸入房間號:");
scanf("%d",StudentList[i].studentroom);
printf("請輸入入住日期:");
scanf("%s",StudentList[i].intime);
printf("請輸入離開日期:");
scanf("%s",StudentList[i].outime);
flag=0;
}
else
printf("未查詢到可供修改數據!");
}
void Delete(int*count)
{int i,j,number,flag=1;
printf("請輸入要刪除數據編號:");
scanf("%d",&number);
for(i=0;i<*count&&flag;i++)
{
if(StudentList[i].number==number) {
for(j=i;j<*count-1;j++)
StudentList[j]=StudentList[j+1];
flag=0;
(*count)--;
}
else
printf("沒有查詢到可刪除數據!");
}
}
編譯是沒有問題了,但是你的程序還缺少東西,比如事先存儲好的數據等,自己再改改吧,這個東西不難,最好自己寫,你懂得。。。。

I. C語言課程設計 酒店管理程序

沒有時間寫,只有一點,朋友給的!

酒店管理

#include<stdio.h>
void xx();
void search();
main()
{ int f;
printf(" ▲***********************▲\n");
printf(" △ 歡迎來到XXX飯店△\n");
printf(" ▲************************▲\n");
printf("1.進入. 2退出.\n");
scanf("%d",&f);
if(f==1)
search();
else
printf("輸入錯誤");
}
void search()
{
int d[15],g[3],a,b,c,x,y,h;
printf("請選擇您需要的號碼:\n1.預定房間\n2.退定房間\n");
scanf("%d",&a);
if(a>3 || a<1)
{printf("您輸入有誤請您重試!\n");
}

else switch(a)
{ case 1:
{ printf("請您輸入您的身份證號碼\n");
scanf("%d",&d[15]);
printf("您已登陸成功^-^\n");
printf("請您選擇退定種類:\n");
printf("1.單人間/夜150元\n2.雙人間/夜200元\n3.標准間/夜300元\n4.總統套房/夜600元\n");
scanf("%d",&b);
switch(b)
{ case 1:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*150);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為202.\n");break;
case 2:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*200);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為305.\n");break;
case 3:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*300);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為208.\n");break;
case 4:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*600);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為306.\n");break;

default :printf("您的輸入有錯請您重試");
}
}break;
case 2:
{printf("請您輸入您的身份證號碼\n");
scanf("%d",&d[15]);
printf("您已登陸成功^-^\n");
printf("請您選擇退訂服務種類:\n");
printf("1.單人間/夜150元\n2.雙人間/夜200元\n3.標准間/夜300元\n4.總統套房/夜600元\n");
scanf("%d",&c);
switch(c)
{case 1:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*150);
printf("您退定成功: 謝謝您的光臨 !\n");break;
case 2:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*200);
printf("您退定成功.謝謝您的光臨 !");break;
case 3:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*300);
printf("您退定成功:謝謝您的光臨 !\n");break;
case 4:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*600);
printf("您退定成功:謝謝您的光臨 !\n");break;
default:printf("您的輸入有錯請您重試");}

}break;}

{
int n;
printf("謝謝光顧\n是否要再預定? 1.是2.否");
scanf("%d",&n);
if(n==1)
search();
else
printf("再見");
}
}