• / 30
  • 下载费用:10 金币  

c语言物业管理系统.doc

关 键 词:
c语言物业管理系统.doc
资源描述:
#include#include#include#ifdef __GNUC__#include#include#define clear clear#define Sleep(x) usleep(x##000)#endif#ifdef _MSC_VER#include#include#define clear system(“cls“)#endif#define TRUE 1#define FAUSE 0typedef struct per{char name[20];int sex;char IDcard[19];char phone[12];int build_num;int unit_num;int house_num;float area;float area_price;float charge;char remarks[200];struct per *next;}PERSON;void zhuce ();int login ();PERSON *Getdata (FILE *fp); void add_person ();void del (PERSON *L);void change (PERSON *L);void sort_All (PERSON *L);void pay (PERSON *L);void sort_B_num (PERSON *L);void menu_1 ();void menu_2 ();int main (){int check,a;printf(“\t************************** Welcome !***********************“);printf(“\n\t\t1.注册“);printf(“\n\t\t2.登录“);printf(“\n\t\t0.退出“);printf(“\n\t--请输入--: “);scanf(“%d“,clear;switch(a){case 0:{printf(“\t\t--感谢使用本系统! --“);Sleep(2000);exit(0);}case 1:{zhuce();clear;check = login();while (check == FAUSE){printf(“\n 用户名或密码错误。 “);Sleep(2000);clear;check = login();}clear;menu_1();break;}case 2:{check = login();while (check == FAUSE){printf (“\n 用户名或密码错误。“);Sleep(2000);clear;check = login();}clear;menu_1();break;}}return 0;}void menu_1 (){FILE *fp;int a;PERSON *head = NULL;printf(“\t\t*************************欢迎使用***************************“);printf(“\n\t\t1.用户添加“);printf(“\n\t\t2.用户修改“);printf(“\n\t\t3.用户删除“);printf(“\n\t\t4.用户费用信息查看“);printf(“\n\t\t5.用户缴费“);printf(“\n\t\t0.退出“);printf(“\n\t--请输入--: “);scanf(“%d“,clear;switch(a){case 0:{printf(“--感谢使用!--“);Sleep(3000);exit(0);}case 1:{add_person();menu_1();break;}case 2:{fp = fopen(“data.dat“,“r“);head = Getdata(fp);printf(“%s“,head-name);if (head == NULL){printf(“没有任何数据“);Sleep(3000);exit(1);}else{change(head);menu_1();}break;}case 3:{if((fp = fopen(“data.dat“,“rb“)) == NULL){printf(“没有任何数据“);exit(1);}else{head = Getdata(fp);del(head);menu_1();}break;}case 4:{menu_2();break;}case 5:{fp = fopen(“data.dat“,“rb“);head = Getdata(fp);if (head == NULL){printf(“没有任何数据“);Sleep(3000);exit(1);}else{pay(head);menu_1();}break;}}}void menu_2 (){FILE *fp;int a;PERSON *head = NULL;printf(“\t\t*******用户信息查看**********“);printf(“\n\t\t1.按楼号查看用户物业费情况“);printf(“\n\t\t2.按费用信息查看用户物业费情况“);printf(“\n\t\t0.退出“);printf(“\n\t--请输入--:“);scanf(“%d“,clear;switch(a){case 0:{printf(“感谢使用“);Sleep(3000);exit(0);}case 1:{fp = fopen(“data.dat“,“rb“);head = Getdata(fp);if (head == NULL){printf(“没有任何数据“);Sleep(3000);exit(1);}else{sort_B_num(head);menu_2();}break;}case 2:{fp = fopen(“data.dat“,“rb“);head = Getdata(fp);if (head == NULL){printf(“没有任何数据 “);Sleep(3000);exit(1);}else{printf(“\t\t--所有用户物业费情况--\n“);sort_All(head);menu_2();}break;}}}void zhuce (){FILE *fp;char ad[50],key0[50],key1[50];char ch;int i,j;printf(“\t\t************用户注册*********“);printf(“\n\t--请输入用户名 : “);scanf(“%s“,ad);while (1){i = 0;j = 0;printf(“\n\t--请输入密码 : “);// initscr();// noecho();while ((ch = getch()) != '\r'){if (ch == 8){printf(“\b “);putchar('\b');if (i 0)i--;}else{putchar('*');// fflush(stdout);key0[i++] = ch;}}// endwin();key0[i] = '\0';printf(“\n\t--请再次输入密码 : “);// initscr();// noecho();while ((ch = getch()) != '\r' ){if (ch == 8){printf(“\b “);putchar('\b');if (j 0)j--;}else{putchar('*');key1[j++] = ch;}}// endwin();key1[j] = '\0';if (strcmp(key0,key1) != 0){clear;printf(“%d“,strcmp(key0,key1));printf(“\t--两次输入密码不符,请重新输入--“);Sleep(2000);clear;}else{printf(“\n--用户 %s 注册成功!--“,ad);Sleep(3000);fp = fopen(“admin.txt“,“a“);fprintf(fp,“%s\n“,ad);fclose(fp);fp = fopen(“key.txt“,“a“);fprintf(fp,“%s\n“,key0);fclose(fp);break;}}}int login (){FILE *fp1,*fp2;char ad[50],key[50];char ch_1[50],ch_2[50],ch_0;int i = 0,check = 0;printf(“\t\t*******************用户登录*********************“);printf(“\n\t\t--[用户名]-- “);scanf(“%s“,ad);printf(“\n\t\t--[密码]-- “);// initscr();while ((ch_0 = getch()) != '\r'){if (ch_0 == 8){printf(“\b “);putchar('\b');if (i 0)i--;}else{putchar('*');key[i++] = ch_0;}}key[i] = '\0';// endwin();fp1 = fopen(“admin.txt“,“r“);fp2 = fopen(“key.txt“,“r“);while (!feof(fp1)){fscanf(fp1,“%s“,ch_1);fscanf(fp2,“%s“,ch_2);// printf(“%s“,ch_1);// printf(“%s“,ch_2);if (strcmp(ad,ch_1) == 0){if (strcmp(key,ch_2) == 0){check = TRUE;break;}}}fclose(fp1);fclose(fp2);return check;}PERSON *Getdata (FILE *fp){PERSON *head = NULL;PERSON *p1,*p2;p1 = (PERSON*)malloc(sizeof(struct per));while (fread(p1,sizeof(struct per),1,fp) == 1){// printf(“%s“,p1-name);if (head = NULL){head = p2 = p1;}else{p2 - next = p1;p2 = p1;}p1 = p1 - next;p1 = (PERSON*)malloc(sizeof(struct per));}p2 - next = NULL;free(p1);return head;}void save (PERSON *head){FILE *fp;PERSON *p;fp = fopen(“data.dat“,“wb+“);p = head;while (p != NULL){fwrite(p,sizeof(struct per),1,fp);p = p - next;}fclose(fp);}void add_person (){PERSON *p1,*p2;PERSON *head = NULL;int n;printf(“\n\t\t************用户添加**********“);while (1){p1 = (PERSON*)malloc(sizeof(struct per));printf(“\n\n 请输入用户信息: 姓名 性别(0.女性;1. 男性) 身份证 联系方式 楼号 单元号 房号 平米数 每平米价格 备注\n\n“);scanf(“%s“,(*p1).name);scanf(“%d“,scanf(“%s“,(*p1).IDcard);scanf(“%s“,(*p1).phone);scanf(“%d“,scanf(“%d“,scanf(“%d“,scanf(“%f“,scanf(“%f“,scanf(“%s“,(*p1).remarks);(*p1).charge = (*p1).area * (*p1).area_price * (-1);if (head = NULL)head = p2 = p1;else{p2 -next = p1;p2 = p1;}printf(“\n\t--用户添加成功! --“);printf(“\n 是否继续添加 (1.是;0.否)“);scanf(“%d“,if (n == 0)break;p1 = p1 - next;}p2 - next = NULL;save(head);}void del (PERSON *L){PERSON *head,*p1,*p2;PERSON *p;char name[20],ID[19];int k = 0;int n;p = (PERSON*)malloc(sizeof(struct per));p - next = head = L;while (1){p1 = p;printf(“请输入所要删除的用户姓名及身份证号\n-- “);scanf(“%s %s“,name,ID);while (p1 - next != NULL){if (strcmp(name,p1-next-name) == 0 p1 - next = p2 - next;free(p2);k = 1;break;}p1 = p1 - next;}head = p - next;if (k == 0)printf(“\n\t--没有相关用户! --“);else{printf(“\n\t 删除用户- %s -成功!“,name);printf(“\n 是否继续删除 (1.是;0 否)“);scanf(“%d“,if (n == 0)break;}}save(head);}void change (PERSON *L){char name[20],ID[19];PERSON *p;int n,k = 0;while (1){p = L;printf(“--请输入所需修改用户的姓名及身份证--\n--“);scanf(“%s“,name);scanf(“%s“,ID);while (p - next != NULL){if (strcmp(p - name,name) == 0 break;}p = p - next;}if (k == 0){printf(“没有查找到该用户,是否重新输入(1.是;0.否)\n--“);scanf(“%d“,if (n != 1)break;}else{clear;printf(“\t--请输入用户 - %s - 修改后信息--“,p - name);printf(“姓名 性别 身份证 联系方式 楼号 单元号 房号 平米数 每平米价格 备注“);scanf(“%s“,(*p).name);scanf(“%d“,scanf(“%s“,(*p).IDcard);scanf(“%s“,(*p).phone);scanf(“%d“,scanf(“%d“,scanf(“%d“,scanf(“%f“,scanf(“%f“,scanf(“%s“,(*p).remarks);(*p).charge = (*p).area * (*p).area_price;printf(“修改用户成功\n 是否继续修改(1.是;0.否)“);scanf(“%d“,if (n != 1)break;}}save(L);}void pay (PERSON *L){char name[20],ID[19];PERSON *head,*p;int n,k = 0;float money;head = L;while (1){printf(“--请输入所需缴费的用户及身份证--\n--“);scanf(“%s %s“,name,ID);p = head;while (p - next != NULL){if (strcmp(p - name,name) == 0 break;}p = p - next;}if (k == 0){printf(“没有查找到该用户,是否重新输入 (1.是;0.否)\n--“);scanf(“%d“,if (n != 1)break;}else{printf(“请输入缴费金额:\n--“);scanf(“%f“,p - charge += money;printf(“是否继续缴费(1. 是;0. 否)“);scanf(“%d“,if (n != 1)break;}}save(head);}void sort_All (PERSON *L){PERSON *p;PERSON s[20],a;int n = 0;int i,j;p = L;while (p - next != NULL){strcpy(s[n].name,p - name);s[n].sex = p - sex;strcpy(s[n].IDcard,p - IDcard);strcpy(s[n].phone,p - phone);s[n].build_num = p - build_num;s[n].unit_num = p - unit_num;s[n].house_num = p - house_num;s[n].area = p - area;s[n].area_price = p - area_price;s[n].charge = p - charge;strcpy(s[n].remarks,p - remarks);n++;p = p - next;}for (i = 0; i s[j].charge){strcpy(a.name,s[j]. name);a.sex = s[j]. sex;strcpy(a.IDcard,s[j]. IDcard);strcpy(a.phone,s[j].phone);a.build_num = s[j].build_num;a.unit_num = s[j]. unit_num;a.house_num = s[j]. house_num;a.area = s[j]. area;a.area_price = s[j].area_price;a.charge = s[j]. charge;strcpy(a.remarks,s[j].remarks);strcpy(s[j].name,s[i].name);s[n].sex = s[i].sex;strcpy(s[j].IDcard,s[i].IDcard);strcpy(s[j].phone,s[i].phone);s[j].build_num = s[i].build_num;s[j].unit_num = s[i].unit_num;s[j].house_num = s[i].house_num;s[j].area = s[i].area;s[j].area_price = s[i].area_price;s[j].charge = s[i].charge;strcpy(s[n].remarks,s[i].remarks);strcpy(s[i].name,a.name);s[i].sex = a.sex;strcpy(s[i].IDcard,a.IDcard);strcpy(s[i].phone,a.phone);s[i].build_num = a.build_num;s[i].unit_num = a.unit_num;s[i].house_num = a.house_num;s[i].area = a.area;s[i].area_price = a.area_price;s[i].charge = a.charge;strcpy(s[n].remarks,a.remarks);}}}printf(“姓名 性别 身份证 联系电话 楼号 单元号 房号 平米数 每平米价格 费用情况 备注“);for (i = 0; i next != NULL){if (p - build_num == 1 a[i].sex = p - sex;strcpy(a[i].IDcard,p - IDcard);strcpy(a[i].phone,p - phone);a[i].build_num = p - build_num;a[i].unit_num = p - unit_num;a[i].house_num = p - house_num;a[i].area = p - area;a[i].area_price = p - area_price;a[i].charge = p - charge;strcpy(a[i].remarks,p - remarks);i++;}if (p - build_num == 2 b[j].sex = p - sex;strcpy(b[j].IDcard,p - IDcard);strcpy(b[j].phone,p - phone);b[j].build_num = p - build_num;b[j].unit_num = p - unit_num;b[j].house_num = p - house_num;b[j].area = p - area;b[j].area_price = p - area_price;b[j].charge = p - charge;strcpy(b[j].remarks,p - remarks);j++;}p = p - next;}printf(“楼号--[1]-- 的欠费用户信息\n“);printf(“姓名 性别 身份证 联系电话 楼号 单元号 房号 平米数 每平米价格 费用情况 备注“);for (n = 0; n i; n++)printf(“%s %d %s %s %d %d %d %.2f %.2f %.2f %s\n“,a[i].name,a[i].sex,a[i].IDcard,a[i].phone,a[i].build_num,a[i].unit_num,a[i].area,a[i].area_price,a[i].charge,a[i].remarks);printf(“楼号--[2]-- 的欠费用户信息\n“);printf(“姓名 性别 身份证 联系电话 楼号 单元号 房号 平米数 每平米价格 费用情况 备注“);for (n = 0; n j; n++)printf(“%s %d %s %s %d %d %d %.2f %.2f %.2f %s\n“,b[j].name,b[j].sex,b[j].IDcard,b[j].phone,b[j].build_num,b[j].unit_num,b[j].area,b[j].area_price,b[j].charge,b[j].remarks);}
展开阅读全文
  微传网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
0条评论

还可以输入200字符

暂无评论,赶快抢占沙发吧。

关于本文
本文标题:c语言物业管理系统.doc
链接地址:https://www.weizhuannet.com/p-9828430.html
微传网是一个办公文档、学习资料下载的在线文档分享平台!

网站资源均来自网络,如有侵权,请联系客服删除!

 网站客服QQ:80879498  会员QQ群:727456886

copyright@ 2018-2028 微传网络工作室版权所有

     经营许可证编号:冀ICP备18006529号-1 ,公安局备案号:13028102000124

收起
展开