commit 1d787fc460783aaf84913e79e17d6423037022d2 Author: 929847918@qq.com <929847918@qq.com> Date: Wed Jan 9 14:08:29 2019 +0800 first commit diff --git a/机房收费系统1.0.c b/机房收费系统1.0.c new file mode 100644 index 0000000..c905383 --- /dev/null +++ b/机房收费系统1.0.c @@ -0,0 +1,335 @@ +#include +#include +#include + +struct time +{ + int hour; + int minute; +}; + +struct student +{ + int no; + char classno[20]; + char name[20]; + struct time begin,end; + struct student *next; +}; + +FILE *pf; +typedef struct student STU; +STU *create_student(); +void end_money(STU *head); +void select_no(STU *head); +void select_classno(STU *head); +void select_name(STU *head); +void add_student(STU *head); +void delect_student(STU *head); +void change_student(STU *head); +void printf_student(STU *head); +int menu_select(); +void show_all(STU *head); +void student_file(STU *head); +STU *studebt_open(); + +int main() +{ + STU *head; + int n=1; + while(n) + { + switch(menu_select()) + { + case 1: + { + system("cls"); + head=create_student(); + student_file(head); + printf("³õʼ»¯ÐÅÏ¢³É¹¦£¡£¨ÐÅÏ¢Òѳɹ¦Â¼ÈëstudentÎļþ£©\n"); + break; + } + case 2: + { + system("cls"); + head=studebt_open(); + end_money(head); + break; + } + case 3: + { + system("cls"); + head=studebt_open(); + select_no(head); + break; + } + case 4: + { + system("cls"); + head=studebt_open(); + select_classno(head); + break; + } + case 5: + { + system("cls"); + head=studebt_open(); + select_name(head); + break; + } + case 6: + { + system("cls"); + head=studebt_open(); + change_student(head); + break; + } + case 7: + { + system("cls"); + head=studebt_open(); + add_student(head); + break; + } + case 8: + { + system("cls"); + head=studebt_open(); + delect_student(head); + break; + } + case 9: + { + system("cls"); + head=studebt_open(); + show_all(head); + } + case 0: + { + n=0; + student_file(head); + printf("±¾´Î²Ù×÷³É¹¦£¬ÒѼÈëÔÚ°¸£¡\n"); + return 0; + break; + } + } + } + system("pause"); + return 0; +} + +int menu_select() +{ + int i; + printf("\t\t**************************************\t\t\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("0.__Í˳öϵͳ\n"); + printf("\t\t*****ÇëÑ¡ÔñÏëҪʵÏֵŦÄÜÐòºÅ*****\t\t\n"); + scanf("%d",&i); + return i; +} + +STU *create_student() +{ + STU *p,*head; + int no,flag=1; + char classno[20],name[20]; + int i,n,begin_hour,begin_minute,end_hour,end_minute; + while(flag) + { + p=(STU*)malloc(sizeof(STU)); + printf("ÇëÊäÈëѧºÅ"); + scanf("%d",&no); + printf("ÇëÊäÈë°à¼¶"); + scanf("%s",&classno); + printf("ÇëÊäÈëÐÕÃû"); + scanf("%s",&name); + printf("ÇëÊäÈëÉÏ»úʱ¼ä"); + scanf("%d%d",&begin_hour,&begin_minute); + printf("ÇëÊäÈëÏ»úʱ¼ä"); + scanf("%d%d",&end_hour,&end_minute); + p->next=NULL; + head->next=p; + head=p; + printf("Í£Ö¹ÊäÈëÇë°´0¼ÌÐøÊäÈëÇë°´1\n"); + scanf("%d",&flag); + } + return head; +} + + +void end_money(STU *head) +{ + STU *p; + float m,k=0.1; + int minute,hour; + int no; + printf("ÇëÊäÈëѧºÅ£º\n"); + scanf("%d",&no); + for(p=head;p;p=p->next) + { + if(no==p->no) + { + if(p->end.minutebegin.minute){ + p->begin.hour--; + minute=p->end.minute+60-p->begin.minute; + }else{ + minute=p->end.minute-p->begin.minute; + } + hour=p->begin.hour-p->end.hour; + minute=hour*60+minute; + m=minute*k; + printf("±¾´ÎÉÏ»úʱ¼äΪ%d·ÖÖÓ£¬Ïû·Ñ½ð¶îΪ%fÔª(×¢£ºÉÏ»ú0.1Ôª/·ÖÖÓ)\n",minute,m); + } + } +} + +void select_no(STU *head) +{ + STU *p; + int no; + printf("ÇëÊäÈëѧºÅ£º\n"); + scanf("%d",&no); + for(p=head;p->next;p=p->next) + { + if(no==p->no) +printf("ѧºÅ£º%d°à¼¶£º%sÐÕÃû£º%sÉÏ»úʱ¼ä£º%d:%dÏ»úʱ¼ä£º%d:%d\n",p->no,p->classno,p->name,p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + } +} + +void select_classno(STU *head) +{ + STU *p; + char classno[20]; + printf("ÇëÊäÈë°à¼¶:\n"); + scanf("%s",&classno); + for(p=head;p;p=p->next) + { + if(strcmp(classno,p->classno)==0) +printf("ѧºÅ£º%s°à¼¶£º%sÐÕÃû£º%sÉÏ»úʱ¼ä£º%d:%dÏ»úʱ¼ä£º%d:%d\n",p->no,p->classno,p->name,p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + } +} + +void select_name(STU *head) +{ + STU *p; + char name[20]; + printf("ÇëÊäÈëÐÕÃû:\n"); + scanf("%s",&name); + for(p=head;p;p=p->next) + { + if(strcmp(name,p->name)==0) +printf("ѧºÅ£º%d°à¼¶£º%sÐÕÃû£º%sÉÏ»úʱ¼ä£º%d:%dÏ»úʱ¼ä£º%d:%d\n",p->no,p->classno,p->name,p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + } +} + +void change_student(STU *head) +{ + STU *p; + int no; + printf("ÇëÊäÈë¸ÃѧÉúµÄѧºÅ£º\n"); + scanf("%d",&no); + for(p=head;p;p=p->next) + { + if(no==p->no) + { + printf("ÇëÊäÈëÐ޸ĺóµÄÉÏ»úʱ¼ä¡¢Ï»úʱ¼ä£º\n"); + scanf("%d%d%d%d",&p->begin.hour,&p->begin.minute,&p->end.hour,&p->end.minute); + printf("%d%d%d%d",p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + printf("Ð޸ijɹ¦£¡"); + } + } +} + +void show_all(STU *head) +{ + STU *p; + for(p=head;p;p=p->next){ +printf("ѧºÅ£º%d°à¼¶£º%sÐÕÃû£º%sÉÏ»úʱ¼ä£º%d:%dÏ»úʱ¼ä£º%d:%d\n",p->no,p->classno,p->name,p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + } +} + +void add_student(STU *head) +{ + STU *p,*q; + int no,begin_hour,begin_minute,end_hour,end_minute; + char classno[20],name[20]; + scanf("%d%s%s%d%d%d%d",&no,&classno,&name,&begin_hour,&begin_minute,&end_hour,&end_hour); + for(p=head;p;p=p->next) + { + if(p->next->next==NULL) + { + p->no=no; + strcpy(p->classno,classno); + strcpy(p->name,name); + p->begin.hour=begin_hour; + p->begin.minute=begin_minute; + p->end.hour=end_hour; + p->end.minute=end_hour; + } + } +} + +void delect_student(STU *head) +{ + STU *p; + int no; + printf("ÇëÊäÈëѧºÅ\n"); + scanf("%d",&no); + for(p=head;p;p=p->next) + { + if(p->next->no==no){ + p=p->next; + } + } +} + +void student_file(STU *head) +{ + STU *p; + int i; + p=head->next; + pf=fopen("student.txt","w+"); + if(pf!=NULL) + { + while(p) + { + fprintf(pf,"%d%s%s%d%d%d%d",p->no,p->classno,p->name,p->begin.hour,p->begin.minute,p->end.hour,p->end.minute); + p=p->next; + } + } + fprintf(pf,"\n"); + fclose(pf); +} + +STU *studebt_open() +{ + char classno[20],name[20]; + int no,begin_hour,begin_minute,end_hour,end_minute; + STU *head,*p,*q; + pf=fopen("student.txt","r"); + head=p=(STU*)malloc(sizeof(STU)); + while(fscanf(pf,"%d%s%s%d%d%d%d",&no,&classno,&name,&begin_hour,&begin_minute,&end_hour,&end_minute)!=EOF) + { + q=(STU*)malloc(sizeof(STU)); + q->no=no; + strcpy(q->classno,classno); + strcpy(q->name,name); + q->begin.hour=begin_hour; + q->begin.minute=begin_minute; + q->end.hour=end_hour; + q->end.minute=end_minute; + p->next=q; + p=q; + } + fclose(pf); + return head; +} diff --git a/机房收费系统1.0.exe b/机房收费系统1.0.exe new file mode 100644 index 0000000..a2c1c77 Binary files /dev/null and b/机房收费系统1.0.exe differ