C++课程设计小区物业管理系统

该系统采用C++编程语言实现,提供了一系列的功能,包括信息输入、数据增加、数据修改、信息查询等,通过文件读写实现数据持久化存储。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include<iomanip>


using namespace std;


class livers//livers类
{ private:
     char name[20]; //姓名
char sex;
char room_num[10];
char parking[10];
     char ID_num[20];
char phone_num[20];


  public:
livers(){}
     livers(char n[20],char s,char room[10],char park[10],char phone[20],char ID[20])
     {strcpy(name,n);
sex=s;
strcpy(room_num,room);
     strcpy(parking,park);
strcpy(phone_num,phone);
strcpy(ID_num,ID);}


   friend void menu();//友元函数
};




void key()
{char mima[20],key[20];char yu_mima[20]="12345";
 int flag;int p;char w;
 ifstream in;
 ofstream out;
 fstream f;  //输入输出对象





 cout<<"      ******************************************"<<endl; 
 cout<<"               欢迎登录小区物业管理系统         "<<endl;
 cout<<"      ******************************************"<<endl<<endl;
 
do{flag=0;
 
   cout<<"      请输入管理员密钥:"<<endl;


   in.clear();
   in.open("E:\\c.dat",ios::in);


   if(in.fail())   //首次登录
   {cout<<endl<<"      欢迎首次登录,您的预设密码为 12345:"<<endl<<endl;
   cout<<"      请输入:";
   cin>>mima;
   cout<<endl;
   if(strcmp(yu_mima,mima)==0)
   {flag=1;
   cout<<"      密码正确!请输入下一步指令:"<<endl<<endl;}}


  if(!in.fail())  //非首次登陆
  {in>>key;
  cin>>mima;
  if(strcmp(key,mima)==0)
  {flag=1;
  cout<<"      密码正确!请输入下一步指令:"<<endl<<endl;}
  }


  in.close();


  if(flag==0)
  cout<<"      密码有误,请重新输入"<<endl<<endl;
}while(flag==0);










 cout<<"              *************************"<<endl;
 cout<<"              *     0、修改密码       *"<<endl;
 cout<<"              *     1、进入系统       *"<<endl;
 cout<<"              *     2、退出系统      *"<<endl;
 cout<<"              *************************"<<endl<<endl;
 do{




 do
 {cout<<"     请输入您的指令(0~2):"<<endl;
  cin>>p;
    
switch(p)
{


 case 0:    //修改密码
{cout<<"     请输入新密码:"<<endl;
cin>>key;
out.open("E:\\c.dat",ios::out);
out.clear();
out<<key;
out.close();}break;


 case 1: menu();break;//进入系统
 case 2:    //退出系统
{cout<<"     谢谢使用,小区物业管理系统!   "<<endl<<endl<<"     Bye-bye!     See you next time!"<<endl<<endl;
exit(0);}break;
default : cout<<"     输入指令有误,请重新输入:"<<endl<<endl;break;
}
}while(p<0||p>2);


 cout<<"    您想继续进行其他操作吗?  y / n  :"<<endl<<" ";
 
 do{cin>>w;
 cout<<endl;
 if(w=='n')exit(0);
 if(w!='y'&&w!='n')
   cout<<"  指令错误!请重新输入!"<<endl;
}while(flag==0);




if(w=='y')
{cout<<"     请输入操作代码: 0 修改密码"<<endl;
cout<<"                     1 进入系统"<<endl;
cout<<"                     2 退出系统"<<endl;}


}while(w=='y');
}   //密钥函数








void menu(
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值