⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 宾馆管理系统.cpp

📁 酒店管理系统
💻 CPP
字号:
#include<stdio.h>
#include<iostream.h>
#include<malloc.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#define newnode() (ptr)malloc(sizeof(message))


typedef struct message
{
	int number;//客房编号(1-1000)
	char type;//客房类型(A B C D)
    float money;//客房单价
	char name[20];//客户信息
    struct message *next;

}mes,*ptr;//存放客房的基本信息

ptr creatlinked_1()
{
	int nu;
	char ty,key;
	float mo;
	ptr head,p;
	printf("请输入客房基本信息\n");
    printf("1:客房编号(1-1000)\n");
	printf("2:客房类型(A B C D)\n");
	printf("3:客房单价\n");
	printf("4:提示:(房号为0结束。)\n");
	printf("         (信息间以空格间隔。)\n");
	head=NULL;
	scanf("%d %c %f",&nu,&ty,&mo);
	while(1)
	{  
		p=newnode();
        p->number=nu;
		p->type=ty;
		p->money=mo;
		p->name[0]='0';
		p->next=head;
		head=p;
		printf("请输入下一组信息。\n");
        scanf("%d",&nu);
		if(nu==0) return(head);
	scanf(" %c %f",&ty,&mo);
	}

}

void outlinked_1(ptr p)
{
	printf("基本信息如下:\n");
	while(p!=NULL)
	{
		printf("%d     %c      %f",p->number,p->type,p->money);
		printf("\n");
		p=p->next;
	}
	printf("\n");
	printf("\n\t\t按任意健继续...");
	getch();
	return;

}//显示客房的基本信息

void findmessage_1(ptr p)
{
	int num;
	printf("客房基本信息查询:\n");
	printf("请输入客房编号:\n");
	scanf("%d",&num);
	while(p)
	{
	  if((p->number)==num)
	   {
	     printf("客房信息如下:\n");
	     printf("%d   %c   %f",p->number,p->type,p->money);
	     printf("\n\t\tPress any key to countinue...");
	     getch();
	     break;
	   }//if
	  else
		p=p->next;

	}//while

}

void modify_kinked_1(ptr p)
{
	int numb;
	int nu_m;
	float mo_m;
	char ty_m;
	printf("请输入要修改的客房编号:\n");
	scanf("%d",&numb);
	while(p)
	{
		if(p->number==numb)
		{
			printf("系统已找到客房信息:\n");
			printf("请输入修改后的信息:\n");
			printf("1:客房编号(1-1000)\n");
		printf("2:客房类型(A B C D)\n");
		printf("3:客房单价(信息间以空格间隔)\n");
	    scanf("%d %c %f",&nu_m,&ty_m,&mo_m);
			p->number=nu_m;
			p->type=ty_m;
			p->money=mo_m;
		    break;
		}//if
		else
			p=p->next;

	}//while

}

void reserve_kinked_1(ptr p)
{
	/*char ty_r;
	printf("请输入要定房间的类型(A B C D)\n");
	scanf("%c%c",&ty_r);
	printf("要查询的%c类客房基本信息如下:",ty_r);
	printf("\n");
	while(p!=NULL)
	{
		if(p->type==ty_r)
		{
			 printf("%d   %c   %f",p->number,p->type,p->money);
			 printf("\n");
		}//if
		else
			p=p->next;


	}//while*/
	int nu_r;
	printf("请输入要定房间的编号:\n");
	scanf("%d",&nu_r);
	while(p)
	{
		if(p->number==nu_r)
		{
			printf("请输您的名字:\n");
	    scanf("%s",p->name);
		printf("\n\t\t您已成功预定房间.");
		printf("\n\t\t按任意键继续...");
		getch();
		break;
		}//if
		else
			p=p->next;

	}//while
}

void outkinked_2(ptr p)
{
    printf("剩余客房信息如下:\n");
	while(p!=NULL)
	{
		if(p->name[0]=='0')
		{printf("%d   %c   %f\n",p->number,p->type,p->money);
		p=p->next;
		}
		//if
		else
			p=p->next;


	}//while
    printf("按任意键继续...");
    getch();
}

void findlinked_2(ptr p)
{
	char key;
	char name_x[20];
	int number_x;
	printf("1:定房信息的显示:\n");
	printf("2: 按名字查询:\n");
	printf("3: 按客房编号查询:\n");
	printf("4: 退出\n");
	while(1)
	{//getch();
	 //system("cls");
	 key=getch();
	 switch(key)
	 {
	    case '1': printf("定房信息如下:\n");
		    while(p!=NULL)
		      {
			if(p->name[0]!='0')
			   {
			     cout<<p->number<<'\t'<<p->type<<'\t'<<p->money<<'\t'<<p->name<<endl;
			     //printf("%d   %c   %f   \n",p->number,p->type,p->money);
			     p=p->next;
			   }
			else
			  p=p->next;
		      };
		      break;
	    case '2': printf("请输入名字:\n");
		    cin>>name_x;
		    while(1)
		       {
			  if(!strcmp(name_x,p->name))
			    {
			      cout<<p->number<<'\t'<<p->type<<'\t'<<p->money<<'\t'<<p->name<<endl;
			      break;
			      //printf("%d   %c   %f   %s\n",p->number,p->type,p->money,p->name);break;
			    }//if
			  else p=p->next;

		       };
		    break;

	    case '3': printf("请输入要查询的客房编号:\n");
		    scanf("%d",&number_x);
		    while(1)
		      {
			if(p->number==number_x)
			  {
			    cout<<p->number<<'\t'<<p->type<<'\t'<<p->money<<'\t'<<p->name<<endl;
			    break;
			  }
			else p=p->next;
		      };
		    break;

	    case '4': return;
	 }//switch

	}//while

}





void main()
{
	char key;
	ptr head;
	printf(" \n\n\n\n\n                 *******欢迎使用宾馆管理系统*******\n");
	printf(" \n\n\n\n\n\n\n\n\n                 -----------------------------------swjtu 李强、\n");
	getch();
	while(1)
	{
	    system("cls");
	    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("0:退出系统。\n");
	    key=getch();
	    switch(key)
		{
		   case '1' : head=creatlinked_1();break;
		   case '2' : outlinked_1(head);break;
		   case '3' : findmessage_1(head);break;
		   case '4' : modify_kinked_1(head);break;
		   case '5' : reserve_kinked_1(head);break;
		   case '6' : outkinked_2(head);break;
		   case '7' : findlinked_2(head);break;
		   case '8' : printf("\n\t\tHaHa,8 is empty!");getch();break;
		   case '9' : printf("\n\t\tHaHa,9 is empty!");getch();break;
		   case '0' : exit(0);
		   default  : printf("\n\t\tInput wrong!");
			      printf("\n\t\tPress any key to countinue...");
			      getch();

		}//switch
	}//while
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -