You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
6.2 KiB

6 years ago
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct time {
int hour;
int minute;
};
struct Student {
long int xuehao;
char banji[10];
char name[10];
int time_hour;
int time_minute;
struct time begin,end;
} ;
struct Student student[30];
static int i=0,j;
void save();
void insert();
void end_money();
void delete_student();
void select_xuehao();
void select_name();
void select_banji();
void show();
int main() {
int menu();
int i;
for(;;)
{
printf("\t\t*******************<2A>˵<EFBFBD>**************\n");
printf("\t\t\n");
printf("\t\t\n");
printf("\t\t***************<2A><><EFBFBD><EFBFBD><EFBFBD>շѹ<D5B7><D1B9><EFBFBD>ϵͳ*******\n");
printf("\t\t\n");
printf("\t\t\n");
printf("\t\t1.###############<23><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ:########\n");
printf("\t\t2.#################<23>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD>:##########\n");
printf("\t\t3.################ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:###########\n");
printf("\t\t4.################<23><>ѧ<EFBFBD>Ų<EFBFBD>ѯ:#########\n");
printf("\t\t5.################<23><><EFBFBD><EFBFBD><E0BCB6>ѯ:#########\n");
printf("\t\t6.################<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ:#########\n");
printf("\t\t7.################<23><>ʾѧ<CABE><D1A7><EFBFBD><EFBFBD>Ϣ:#######\n");
printf("\t\t8.##################<23>˳<EFBFBD>ϵͳ:#########\n");
printf("\n\n\n\n<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>1-8<><38>֮<EFBFBD><D6AE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&i);
switch(i)
{
case 1:
{
system("cls");
insert();
}
break;
case 2:
{
system("cls");
end_money();
}
break;
case 3:
{
system("cls");
delete_student();
}
break;
case 4:
{
system("cls");
select_xuehao();
}
break;
case 5:
{
system("cls");
select_banji();
}
break;
case 6:
{
system("cls");
select_name();
}
break;
case 7:
{
system("cls");
show();
} break;
case 8:
{
exit(0);
}
break;
}
}
printf("\n"); system("pause");
save();
return 0;
}
void insert() {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld",&student[i].xuehao);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",student[i].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶:");
scanf("%s",student[i].banji);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>:");
scanf("%d:%d",&student[i].begin.hour,&student[i].begin.minute);
i = i + 1;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d",i);
j=i;
save();
printf("\n"); system("pause");
system("cls");
}
6 years ago
void end_money() {
int m,minute,hour;
6 years ago
long int xuehao;
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld",&xuehao);
for(m = 0; m < i; m++)
{
if(student[m].xuehao==xuehao)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%ld<6C><64><EFBFBD>»<EFBFBD>ʱ<EFBFBD><CAB1>:",xuehao);
scanf("%d:%d",&student[m].end.hour,&student[m].end.minute);
if(student[m].end.minute<student[m].begin.minute)
{
minute=student[m].end.minute+60
-student[m].begin.minute;
hour=student[m].end.hour-1-student[m].begin.hour;
student[m].time_hour = hour;
student[m].time_minute = minute;
}
else
{
minute=student[m].end.minute -student[m].begin.minute;
hour=student[m].end.hour -student[m].begin.hour;
student[m].time_hour = hour;
student[m].time_minute = minute;
}
if(minute > 0)
{
hour = hour + 1;
printf("<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%d:%d <20><><EFBFBD><EFBFBD>Ϊ:%d",student[m].time_hour,student[m].time_minute,hour);
}
else {
printf("<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%d:%d\n <20><><EFBFBD><EFBFBD>Ϊ:%d",student[m].time_hour,student[m].time_minute,hour);
}
}
}
save();
printf("\n"); system("pause");
system("cls");
}
6 years ago
void delete_student()
{
long int xuehao;
int m;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld",&xuehao);
if(i==1)
{
if(student[m].xuehao==xuehao)
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
}
else{
for(m=0;m<i-1;m++)
if(student[m].xuehao==xuehao)break;
for(;m<i;m++) student[m]=student[m+1];
}
save();
printf("\n");
system("pause");
system("cls");
}
6 years ago
void select_xuehao() {
long int xuehao;
int m;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld",&xuehao);
for(m = 0; m < i; m++)
{
if(student[m].xuehao==xuehao)
{
printf("ѧ<EFBFBD><EFBFBD>:%ld\t",student[m].xuehao);
printf(" <20>༶:%s\t",student[m].banji);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s\t",student[m].name);
printf(" <20>ϻ<EFBFBD><CFBB><EFBFBD>ʼʱ<CABC><CAB1>:%d:%d\t",student[m].begin.hour,student[m].begin.minute);
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>:%d:%d\t",student[m].end.hour,student[m].end.minute);
printf("<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>:%d:%d\n\t",student[m].time_hour,student[m].time_minute);
}
else if( m == i)
{
printf("û<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:\n");
}
}
save();
printf("\n"); system("pause");
system("cls");
6 years ago
}
void select_banji() {
6 years ago
char banji[10];
int m;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>༶:");
scanf("%s",banji);
for(m = 0; m < i; m++)
{
if(!strcmp(banji,student[m].banji)) {
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%ld\t",student[m].xuehao);
printf("<EFBFBD><EFBFBD><EFBFBD>:%s\t",student[m].banji);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s\t",student[m].name);
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD>ʼʱ<EFBFBD><EFBFBD>:%d:%d\t",student[m].begin.hour,student[m].begin.minute);
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>:%d:%d\t",student[m].end.hour,student[m].end.minute);
printf("<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%d:%d\n",student[m].time_hour,student[m].time_minute);
}
else if( m == i)
{
printf("û<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:\n");
}
}save();
printf("\n"); system("pause");
system("cls");
6 years ago
}
6 years ago
void select_name()
{char name[10];
int m;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",name);
for(m=0;m<i;m++)
{
if(!strcmp(name,student[m].name))
{
printf("ѧ<EFBFBD><EFBFBD>Ϊ%ld\t",student[m].xuehao);
printf("<EFBFBD>༶Ϊ%s\t",student[m].banji);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ%s\t",student[m].name);
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD>ʼʱ<EFBFBD><EFBFBD>:%d:%d\t",student[m].begin.hour,student[m].begin.minute);
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>:%d:%d\t",student[m].end.hour,student[m].end.minute);
printf("<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%d:%d\n",student[m].time_hour,student[m].time_minute);
}
else if(m==i)
{
printf("û<EFBFBD>м<EFBFBD>¼:\n");
}
}save();
system("pause");
system("cls");
}
void save()
{
FILE *fp;
int m;
fp=fopen("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.txt","w");
for(m=0;m<i;m++)
{
fprintf(fp,"%ld %s %s %d %d %d %d %d %d %d %d\n",student[m].xuehao,student[m].banji,student[m].name,student[m].begin.hour,student[m].begin.minute,student[m].end.hour,student[m].end.minute,student[m].time_hour,student[m].time_minute);
}
fclose(fp);
}
void show()
{
int m;
printf("ѧ<EFBFBD><EFBFBD> <20><20><><EFBFBD><EFBFBD> <20>ϻ<EFBFBD>ʱ<EFBFBD><CAB1> <20>»<EFBFBD>ʱ<EFBFBD><CAB1> <20><>ʱ\n");
for(m=0;m<i;m++)
{printf("%ld %s %s %d:%d %d:%d %d:%d\n",student[m].xuehao,student[m].banji,student[m].name,student[m].begin.hour,student[m].begin.minute,student[m].end.hour,student[m].end.minute,student[m].time_hour,student[m].time_minute);
}
system("pause");
system("cls");
}