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

📄 小区物业管理系统.cpp

📁 我以前做的一个C语言课程设计
💻 CPP
📖 第 1 页 / 共 2 页
字号:
   }
   else
   {

	   while(kk->link!=k)
          kk=kk->link;
      kk->link=k->link;
	   free(k);
   }
   printf("删除成功!\n");
   save2(k);
}
void save1(struct yezhu *p)
{   
	FILE *fp;
	fp=fopen("yezhu.dat","w");
	p=phead;
	while(p!=NULL)
	{
		fwrite(p,sizeof(struct yezhu),1,fp);
		p=p->next;
	}
	fclose(fp);
	
}
void Read1()
{
	FILE *fp;
	struct yezhu *p;
	fp=fopen("yezhu.dat","r");
    while(1)
	{
		p=(struct yezhu *)malloc(sizeof(struct yezhu));
		if(feof(fp))
			break;
		if(fread(p,sizeof(struct yezhu),1,fp))
		 myAdd3(p);
	}

	fclose(fp);

}
void wuyemenu()
{
	int choose=0;
	do
	{
	  printf("*********************************物业费用管理系统************************\n");
	  printf("-------------------------------------------------------------------------\n");
	  printf("* * * * * * * * * * * * * * * 〓请选择〓(1~5)* * * * * * * * * * * * *\n");
	  printf("*                                                                       * \n");
	  printf("*                                                                       *\n");
	  printf("*                            ⒈物业信息录入;                           *\n");
	  printf("*                                                                       *\n");
      printf("*                            ⒉物业信息修改;                           *\n");
	  printf("*                                                                       *\n");
      printf("*                            ⒊物业信息删除;                           *\n");
      printf("*                                                                       *\n");
	  printf("*                            ⒋物业信息浏览;                           *\n");
	  printf("*                                                                       *\n");
	  printf("*                            ⒌返回上级菜单。                           *\n");
	  printf("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
	  printf("请输入选项:");
      scanf("%d",&choose);
	  switch(choose)
	  {
	       case 1: myAdd2();
			   break;
		   case 2: myReplace2();
			   break;
		   case 3: myDelete2();
			   break;
		   case 4: Display2();
			   break;
           case 5: return;
           default:printf("输入错误,请重新输入:\n");
	  }
	}
	  while(1);
}
void myAdd2()//录入物业信息//	
{   
	struct wuye *p;
    struct yezhu *t;
	int x=0;
	p=(struct wuye *)malloc(sizeof(struct wuye));
	printf("请录入物业信息:\n");
	printf("ID:");
	scanf("%s",p->ID);
	t=find1(p->ID);
	if(t=find1(p->ID));
	else 
	{
		printf("无此业主ID!\n");
		return;
	}
	printf("上一次缴费年份:");
	scanf("%d",&p->last_year);
	printf("月份:");
	scanf("%d",&p->last_month);
    printf("缴费金额:");
	scanf("%f",&p->money);
	x=p->money/(0.4*t->area);
	p->to_time=(int)x;
	myAdd4(p);
	save2(p);
	printf("录入成功!\n");
}
struct wuye *myAdd4(struct wuye *p)//添加物业信息结点//
{
   struct wuye *t;
   if(pHead==NULL)
	{
		pHead=p;
		p->link=NULL;
	}
	else
	{
       t=pHead;
	   while(t->link!=NULL)
		   t=t->link;
	   t->link=p;
	   p->link=NULL;
	}
	return pHead;
}
struct wuye *find2(char *id)//通过姓名查找缴费信息//
{
	   struct wuye *p;
	   p=pHead;
	   while(p!=NULL)
	   {
		   if(strcmp(p->ID,id)==0)
			   return p;
		   p=p->link;
	   }
	   return NULL;
}
void myfind()
{   
	struct wuye *p;
	char a[100];
	printf("请输入要查找的业主id:");
	scanf("%s",a);
	p=find2(a); 
	if(p=find2(a)); 
    else 
	{
		printf("业主尚没存缴信息!\n");
		return;
	}
	Display(p);
}
void myReplace2()
{
	struct wuye *k;
	struct yezhu *t;
	char id[20];
	int x;
	printf("请输入要修改的业主ID:");
	scanf("%s",id);
	if(k=find2(id));
	else 
	{
		printf("无此业主ID!\n");
		return;
	}
	printf("您要修改的信息为:\n");
  	printf("请输入新的信息:\n");
	printf("ID:");
    	scanf("%s",k->ID);
	printf("上一次缴费年份:");
    	scanf("%d",&k->last_year);
    printf("月份:");
		scanf("%d",&k->last_month);
	printf("缴费金额:");
    	scanf("%f",&k->money);
		t=find1(k->ID);
	x=(int)k->money/(0.4*t->area);
	k->to_time=(int)x;
    myAdd4(k);
	save2(k);
	printf("修改成功!\n");
}
void myDelete2()
{  
   struct wuye *p,*pp;
   char id[100];
   pp=pHead;
   printf("请输入要删除人的ID:");
   scanf("%s",id);
   p=find2(id);
   if(p=find2(id));
   else 
   {
		printf("无此业主ID!\n");
		return;
   }
   if(p==pHead)
   {
	  pHead=p->link;
	  free(p);
   }
   else
   {

	   while(pp->link!=p)
          pp=pp->link;
       pp->link=p->link;
	   free(p);
   }
   save2(p);
   printf("删除成功!\n");
}
void Display2()
{   
	struct wuye *p;
	p=pHead;
	while(p!=NULL)
	{
		printf("ID:%s\n",p->ID);
	    printf("最后一次缴费日期:%d年%d月\n",p->last_year,p->last_month);
		printf("缴费金额:%f元\n",p->money);
	    printf("费用有效期:%d个月\n",p->to_time);
		printf("\n\n\n");
        p=p->link;
	}
}
void Display(struct wuye *p)
{ 
		printf("业主ID:%s\n",p->ID);
	    printf("最后一次缴费日期:%d年%d月\n",p->last_year,p->last_month);
		printf("最后一次缴费金额:%f\n",p->money);
	    printf("费用有效期:%d个月\n",p->to_time);
}
void Read2()
{
	FILE *fp;
	struct wuye *p;
	fp=fopen("wuye.dat","rb");
    while(1)
	{
		p=(struct wuye *)malloc(sizeof(struct wuye));
		if(feof(fp))
			break;
		if(fread(p,sizeof(struct wuye),1,fp))
		 myAdd4(p);
	}

	fclose(fp);

}
void save2(struct wuye *p)
{
	
	FILE *fp;
	fp=fopen("wuye.dat","wb");
	p=pHead;
	while(p!=NULL)
	{
		fwrite(p,sizeof(struct wuye),1,fp);
		p=p->link;
	}
	fclose(fp);
	
}
void mychaozhao()
{
	int year,month;
	struct wuye *k;
	struct yezhu *l;
	k=pHead;
	l=phead;
    printf("请输入当前年份:");
	scanf("%d",&year);
	printf("请输入当前月份:");
	scanf("%d",&month);
	while(k!=NULL)
	{
		    if(year>k->last_year)
			{
				l=find1(k->ID);
				l->lost=(float)(month+12-k->to_time-k->last_month)*(0.4*l->area);
				if(l->lost>0)
				{
					printf("业主ID*:%s\n",l->id);
                    printf("业主姓名*:%s\n",l->name);
					printf("最后一次缴费日期:%d年%d月\n",k->last_year,k->last_month);
			        printf("欠费金额*:%f\n",l->lost);
					printf("\n\n");
				}
			}
		
			if(year=k->last_year)
			{
				l=find1(k->ID);
				l->lost=(float)(month-k->to_time-k->last_month)*(0.4*l->area);
                if(l->lost>0)
				{
					printf("业主ID:%s\n",l->id);
                    printf("业主姓名:%s\n",l->name);
					printf("最后一次缴费日期:%d年%d月\n",k->last_year,k->last_month);
			        printf("欠费金额:%f\n",l->lost);
					printf("\n\n");
				}
			}   
	       	k=k->link;
	}
}
void main()
{   
	Read1();
	Read2();
    int m;
	do
	{
	    m=mainmenu();
	    switch(m)
		{
	     case 1: xinximenu();break;
         case 2: tongjimenu();break;
         case 3:printf("*****************************谢谢使用,再见!***********************************\n");
			 exit(0);
		}
	}
	while(1);
}

⌨️ 快捷键说明

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