|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
struct time
|
|
|
|
|
{
|
|
|
|
|
int hour;
|
|
|
|
|
int minute;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct student
|
|
|
|
|
{
|
|
|
|
|
int no;
|
|
|
|
|
int classno;
|
|
|
|
|
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_write(STU *head);
|
|
|
|
|
STU *student_read();
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
STU *head;
|
|
|
|
|
int n=1,k=0;
|
|
|
|
|
while(n)
|
|
|
|
|
{
|
|
|
|
|
switch(menu_select())
|
|
|
|
|
{
|
|
|
|
|
if(k==1)
|
|
|
|
|
{
|
|
|
|
|
head=student_read();
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
head=create_student();
|
|
|
|
|
student_write(head);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ѳɹ<EFBFBD>¼<EFBFBD><EFBFBD>student<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
k=1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
end_money(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
select_no(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
select_classno(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
select_name(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 6:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
change_student(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 7:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
add_student(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 8:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
delect_student(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 9:
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
show_all(head);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
n=0;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int menu_select()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
printf("\t\t**************************************\t\t\n");
|
|
|
|
|
printf("1.__<5F><5F>ʼ<EFBFBD><CABC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("2.__<5F><5F><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("3.__<5F><5F>ѧ<EFBFBD>Ų<EFBFBD>ѯ\n");
|
|
|
|
|
printf("4.__<5F><5F><EFBFBD>༶<EFBFBD><E0BCB6>ѯ\n");
|
|
|
|
|
printf("5.__<5F><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ\n");
|
|
|
|
|
printf("6.__<5F><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("7.__<5F><5F><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("8.__ɾ<5F><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("9.__<5F><5F>ʾȫ<CABE><C8AB><EFBFBD>ϻ<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("0.__<5F>˳<EFBFBD>ϵͳ\n");
|
|
|
|
|
printf("\t\t*****<2A><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ҫʵ<D2AA>ֵĹ<D6B5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*****\t\t\n");
|
|
|
|
|
scanf("%d",&i);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STU *create_student()
|
|
|
|
|
{
|
|
|
|
|
STU *p,*head,*tail;
|
|
|
|
|
int no,classno,flag=1;
|
|
|
|
|
char name[20];
|
|
|
|
|
int begin_hour,begin_minute,end_hour,end_minute;
|
|
|
|
|
while(flag)
|
|
|
|
|
{
|
|
|
|
|
p=(STU*)malloc(sizeof(STU));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%d",&no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶");
|
|
|
|
|
scanf("%d",&classno);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",&name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%d%d",&begin_hour,&begin_minute);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD>ʱ<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%d%d",&end_hour,&end_minute);
|
|
|
|
|
p->no=no;
|
|
|
|
|
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_minute;
|
|
|
|
|
p->next=NULL;
|
|
|
|
|
if(head==NULL)
|
|
|
|
|
{
|
|
|
|
|
head=p;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tail->next=p;
|
|
|
|
|
}
|
|
|
|
|
tail=p;
|
|
|
|
|
printf("ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>\n");
|
|
|
|
|
scanf("%d",&no);
|
|
|
|
|
for(p=head;p;p=p->next)
|
|
|
|
|
{
|
|
|
|
|
if(no==p->no)
|
|
|
|
|
{
|
|
|
|
|
if(p->end.minute<p->begin.minute){
|
|
|
|
|
p->begin.hour--;
|
|
|
|
|
minute=p->end.minute+60-p->begin.minute;
|
|
|
|
|
}else{
|
|
|
|
|
minute=p->end.minute-p->begin.minute;
|
|
|
|
|
}
|
|
|
|
|
hour=p->end.hour-p->begin.hour;
|
|
|
|
|
minute=hour*60+minute;
|
|
|
|
|
m=minute*k;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ%d<><64><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>Ϊ%fԪ(ע<><D7A2><EFBFBD>ϻ<EFBFBD>0.1Ԫ/<2F><><EFBFBD><EFBFBD>)\n",minute,m);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void select_no(STU *head)
|
|
|
|
|
{
|
|
|
|
|
STU *p;
|
|
|
|
|
int no;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>\n");
|
|
|
|
|
scanf("%d",&no);
|
|
|
|
|
for(p=head;p;p=p->next)
|
|
|
|
|
{
|
|
|
|
|
if(no==p->no)
|
|
|
|
|
printf("ѧ<EFBFBD>ţ<EFBFBD>%d<>༶<EFBFBD><E0BCB6>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<>ϻ<EFBFBD>ʱ<EFBFBD>䣺%d:%d<>»<EFBFBD>ʱ<EFBFBD>䣺%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;
|
|
|
|
|
int classno;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶:\n");
|
|
|
|
|
scanf("%d",&classno);
|
|
|
|
|
for(p=head;p;p=p->next)
|
|
|
|
|
{
|
|
|
|
|
if(classno==p->classno)
|
|
|
|
|
printf("ѧ<EFBFBD>ţ<EFBFBD>%d<>༶<EFBFBD><E0BCB6>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<>ϻ<EFBFBD>ʱ<EFBFBD>䣺%d:%d<>»<EFBFBD>ʱ<EFBFBD>䣺%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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",&name);
|
|
|
|
|
for(p=head;p;p=p->next)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(name,p->name)==0)
|
|
|
|
|
printf("ѧ<EFBFBD>ţ<EFBFBD>%d<>༶<EFBFBD><E0BCB6>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<>ϻ<EFBFBD>ʱ<EFBFBD>䣺%d:%d<>»<EFBFBD>ʱ<EFBFBD>䣺%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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>\n");
|
|
|
|
|
scanf("%d",&no);
|
|
|
|
|
for(p=head;p;p=p->next)
|
|
|
|
|
{
|
|
|
|
|
if(no==p->no)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD>䡢<EFBFBD>»<EFBFBD>ʱ<EFBFBD>䣺\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("<EFBFBD>ijɹ<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void show_all(STU *head)
|
|
|
|
|
{
|
|
|
|
|
STU *p;
|
|
|
|
|
for(p=head;p;p=p->next){
|
|
|
|
|
printf("ѧ<EFBFBD>ţ<EFBFBD>%d <20>༶<EFBFBD><E0BCB6>%d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s <20>ϻ<EFBFBD>ʱ<EFBFBD>䣺%d:%d <20>»<EFBFBD>ʱ<EFBFBD>䣺%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,classno,begin_hour,begin_minute,end_hour,end_minute;
|
|
|
|
|
char name[20];
|
|
|
|
|
scanf("%d%d%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;
|
|
|
|
|
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,*q;
|
|
|
|
|
int no;
|
|
|
|
|
p=head;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
scanf("%d",&no);
|
|
|
|
|
if(p->next->no==no)
|
|
|
|
|
{
|
|
|
|
|
q=p->next;
|
|
|
|
|
p->next=q->next;
|
|
|
|
|
free(q);
|
|
|
|
|
}
|
|
|
|
|
show_all(head);
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void student_write(STU *head)
|
|
|
|
|
{
|
|
|
|
|
STU *p;
|
|
|
|
|
int i;
|
|
|
|
|
p=head;
|
|
|
|
|
pf=fopen("student.txt","a+");
|
|
|
|
|
if(pf!=NULL)
|
|
|
|
|
{
|
|
|
|
|
while(p)
|
|
|
|
|
{
|
|
|
|
|
fprintf(pf,"%d%d%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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("error!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
fclose(pf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STU *student_read()
|
|
|
|
|
{
|
|
|
|
|
char name[20];
|
|
|
|
|
int no,classno,begin_hour,begin_minute,end_hour,end_minute;
|
|
|
|
|
STU *head,*p,*q;
|
|
|
|
|
pf=fopen("student.txt","a+");
|
|
|
|
|
head=p=(STU*)malloc(sizeof(STU));
|
|
|
|
|
while(fscanf(pf,"%d%d%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;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|