|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
struct stu /*<2A><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
char num[15];
|
|
|
|
|
char banji[10];
|
|
|
|
|
char name[25];
|
|
|
|
|
int hour1;
|
|
|
|
|
int hour2;
|
|
|
|
|
int min1;
|
|
|
|
|
int min2;
|
|
|
|
|
}st[99];
|
|
|
|
|
void menu() /*<2A>˵<EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
printf("\t**************************\n");
|
|
|
|
|
printf("\t****1---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**********\n");
|
|
|
|
|
printf("\t****2---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**********\n");
|
|
|
|
|
printf("\t****3---ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**********\n");
|
|
|
|
|
printf("\t****4---<2D><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>**********\n");
|
|
|
|
|
printf("\t**************************\n");
|
|
|
|
|
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Իس<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
void new_students(int *p);
|
|
|
|
|
void calculate(struct stu st[],int *q);
|
|
|
|
|
void del(int *p);
|
|
|
|
|
void search(int *p);
|
|
|
|
|
void main() /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
int b=0;
|
|
|
|
|
int a,*p;
|
|
|
|
|
FILE *fpp; /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ָ<EFBFBD><D6B8>*/
|
|
|
|
|
p=&b;
|
|
|
|
|
if((fpp=fopen("stu_num.txt","r"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><EFBFBD>¼");
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fread(p,4,1,fpp);
|
|
|
|
|
fclose(fpp);
|
|
|
|
|
}
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
menu();
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
switch(a)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
new_students(p); break;
|
|
|
|
|
case 2:
|
|
|
|
|
calculate(st,p); break;
|
|
|
|
|
case 3:
|
|
|
|
|
del(p); break;
|
|
|
|
|
case 4:
|
|
|
|
|
search(p); break;
|
|
|
|
|
case 5:
|
|
|
|
|
{
|
|
|
|
|
system("pause");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
default :
|
|
|
|
|
printf("continue\n");
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void new_students(int *p) /*<2A><><EFBFBD>뺯<EFBFBD><EBBAAF>*/
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
FILE *fpp;
|
|
|
|
|
for(i=*p;i<*p+1;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ!\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>Ϊ:");
|
|
|
|
|
scanf("%s",&st[i].num);
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
printf("<EFBFBD>༶Ϊ:");
|
|
|
|
|
scanf("%s",&st[i].banji);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:");
|
|
|
|
|
scanf("%s",&st[i].name);
|
|
|
|
|
printf("<EFBFBD>ϻ<EFBFBD>СʱΪ:");
|
|
|
|
|
scanf("%d",&st[i].hour1);
|
|
|
|
|
printf("<EFBFBD>ϻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:");
|
|
|
|
|
scanf("%d",&st[i].min1);
|
|
|
|
|
printf("<EFBFBD>»<EFBFBD>СʱΪ:");
|
|
|
|
|
scanf("%d",&st[i].hour2);
|
|
|
|
|
printf("<EFBFBD>»<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:");
|
|
|
|
|
scanf("%d",&st[i].min2);
|
|
|
|
|
}
|
|
|
|
|
if(*p==0)
|
|
|
|
|
{
|
|
|
|
|
if((fp=fopen("stu_menu.txt","w"))==NULL)
|
|
|
|
|
printf("cannot open file");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fp=fopen("stu_menu.txt","r+");
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
fread(&st[i],sizeof(struct stu),1,fp); /*д<><D0B4><EFBFBD>ļ<EFBFBD>*/
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<*p+1;i++)
|
|
|
|
|
if(fwrite(&st[i],sizeof(struct stu),1,fp)!=1)
|
|
|
|
|
fclose(fp);
|
|
|
|
|
*p=*p+1;
|
|
|
|
|
if((fpp=fopen("stu_num.txt","w"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("cannot open file");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(fwrite(p,4,1,fpp)!=1)
|
|
|
|
|
printf("file write error");
|
|
|
|
|
fclose(fpp);
|
|
|
|
|
}
|
|
|
|
|
void calculate(struct stu st[],int *q)
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char a;
|
|
|
|
|
fp=fopen("stu_menu.txt","r"); /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
|
|
|
|
|
for(i=0;i<*q;i++)
|
|
|
|
|
{
|
|
|
|
|
fread(&st[i],sizeof(struct stu),1,fp);
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>Ϊ:%s\t <20>༶Ϊ:%s\t <20><><EFBFBD><EFBFBD>Ϊ:%s\t",st[i].num,st[i].banji,st[i].name);
|
|
|
|
|
printf("\t<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour1,st[i].min1);
|
|
|
|
|
printf("\t<EFBFBD>»<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour2,st[i].min2);
|
|
|
|
|
if(st[i].min1<=st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60+(st[i].min2-st[i].min1);
|
|
|
|
|
else if(st[i].min1>st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1-1)*60+(60-st[i].min1+st[i].min2);
|
|
|
|
|
else if(st[i].min1==0&&st[i].min2==0)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%dԪ",j);
|
|
|
|
|
}
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
a=getchar();
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
void del(int *p) /*ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
char a[9];
|
|
|
|
|
FILE *fp;
|
|
|
|
|
FILE *fpp;
|
|
|
|
|
fp=fopen("stu_menu.txt","r+");
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
fread(&st[i],sizeof(struct stu),1,fp);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",a);
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(a,st[i].name)==0)
|
|
|
|
|
{
|
|
|
|
|
for(j=i;j<*p-1;j++)
|
|
|
|
|
{
|
|
|
|
|
strcpy(st[j].num,st[j+1].num);
|
|
|
|
|
strcpy(st[j].banji,st[j+1].banji);
|
|
|
|
|
st[j].hour1=st[j+1].hour1;
|
|
|
|
|
st[j].min1=st[j+1].min1;
|
|
|
|
|
st[j].hour2=st[j+1].hour2;
|
|
|
|
|
st[j].min2=st[j+1].min2;
|
|
|
|
|
strcpy(st[j].name,st[j+1].name);
|
|
|
|
|
}
|
|
|
|
|
*p=*p-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
fwrite(&st[i],sizeof(struct stu),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
if((fpp=fopen("stu_num.txt","w"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("cann't open file");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(fwrite(p,4,1,fp)!=1)
|
|
|
|
|
printf("file write error");
|
|
|
|
|
fclose(fpp);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
void search(int *p) /*<2A><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
int a,i,c=1,j;
|
|
|
|
|
char b[9];
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("stu_menu.txt","r");
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
fread(&st[i],sizeof(struct stu),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("**<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**\n");
|
|
|
|
|
printf("1:ѧ<><D1A7> 2:<3A><><EFBFBD><EFBFBD> 3:<3A>༶\n");
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
switch(a) /*ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ҷ<EFBFBD>ʽ*/
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",b);
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
if(strcmp(b,st[i].num)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>Ϊ:%s <20>༶Ϊ:%s <20><><EFBFBD><EFBFBD>Ϊ:%s",st[i].num,st[i].banji,st[i].name);
|
|
|
|
|
printf("\t<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour1,st[i].min1);
|
|
|
|
|
printf("\t<EFBFBD>»<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour2,st[i].min2);
|
|
|
|
|
if(st[i].min1<=st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60+(st[i].hour2-st[i].hour1);
|
|
|
|
|
else if(st[i].min1>st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1-1)*60+(60-st[i].min1+st[i].min2);
|
|
|
|
|
else if(st[i].min1==0&&st[i].min2==0)
|
|
|
|
|
j=st[i].hour2-st[i].hour1;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%dԪ",j);
|
|
|
|
|
c=0;
|
|
|
|
|
}
|
|
|
|
|
if(c==1)
|
|
|
|
|
{
|
|
|
|
|
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",b);
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
if(strcmp(b,st[i].name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>Ϊ:%s <20>༶Ϊ:%s <20><><EFBFBD><EFBFBD>Ϊ:%s",st[i].num,st[i].banji,st[i].name);
|
|
|
|
|
printf("\t<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour1,st[i].min1);
|
|
|
|
|
printf("\t<EFBFBD>»<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour2,st[i].min2);
|
|
|
|
|
if(st[i].min1<=st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60+(st[i].min2-st[i].min1);
|
|
|
|
|
else if(st[i].min1>st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1-1)*60+(60-st[i].min1+st[i].min2);
|
|
|
|
|
else if(st[i].min1==0&&st[i].min2==0)
|
|
|
|
|
j=st[i].hour2-st[i].hour1;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%dԪ",j);
|
|
|
|
|
c=0;
|
|
|
|
|
}
|
|
|
|
|
if(c==1)
|
|
|
|
|
{
|
|
|
|
|
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD>༶");
|
|
|
|
|
scanf("%s",b);
|
|
|
|
|
for(i=0;i<*p;i++)
|
|
|
|
|
if(strcmp(b,st[i].banji)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD>Ϊ:%s <20>༶Ϊ:%s <20><><EFBFBD><EFBFBD>Ϊ:%s",st[i].num,st[i].banji,st[i].name);
|
|
|
|
|
printf("\t<EFBFBD>ϻ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour1,st[i].min1);
|
|
|
|
|
printf("\t<EFBFBD>»<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ:%dʱ%d<><64>",st[i].hour2,st[i].min2);
|
|
|
|
|
if(st[i].min1<=st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60+(st[i].min2-st[i].min1);
|
|
|
|
|
else if(st[i].min1>st[i].min2)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1-1)*60+(60-st[i].min1+st[i].min2);
|
|
|
|
|
else if(st[i].min1==0&&st[i].min2==0)
|
|
|
|
|
j=(st[i].hour2-st[i].hour1)*60;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:%dԪ",j);
|
|
|
|
|
c=0;
|
|
|
|
|
}
|
|
|
|
|
if(c==1)
|
|
|
|
|
{
|
|
|
|
|
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
default :
|
|
|
|
|
printf("û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
|
|
|
|
|
}
|
|
|
|
|
}
|