|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#define file "d:\\student.txt"
|
|
|
|
|
#define N 3
|
|
|
|
|
struct student{//<2F><><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|
|
|
|
char number[20];
|
|
|
|
|
char name[20];
|
|
|
|
|
char sex;
|
|
|
|
|
int age;
|
|
|
|
|
char beizhu[100];
|
|
|
|
|
};
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void menu()//<2F>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("+ <20><>ӭ +\n");
|
|
|
|
|
printf("+ <20>༶<EFBFBD><E0BCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ +\n");
|
|
|
|
|
printf("+ 1.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> +\n");//Entry
|
|
|
|
|
printf("+ 2.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ +\n");//Display
|
|
|
|
|
printf("+ 3.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> +\n");//Save
|
|
|
|
|
printf("+ 4.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣɾ<CFA2><C9BE> +\n");//Delete
|
|
|
|
|
printf("+ 5.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD> +\n");//Modify
|
|
|
|
|
printf("+ 6.ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ѯ +\n");//Search
|
|
|
|
|
printf("+ 7.<2E>˳<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣϵͳ +\n");//ExitFuction
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void Entry(struct student arr[],int n)//luru
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ ѧ<><D1A7> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
|
|
|
|
|
scanf("%s %s %c %d %s",&arr[i].number,&arr[i].name,&arr[i].sex,&arr[i].age,&arr[i].beizhu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void Display(struct student arr[],int n)//xianshi
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ ѧ<><D1A7> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%15s%15s%15c%15d%15s",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void save(struct student arr[],int n)//baocun
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("d:\\student.txt","w+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
fwrite(arr,sizeof(struct student)*n,n,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void Delete(struct student*arr,int n)//shanchu
|
|
|
|
|
{
|
|
|
|
|
int i,c;
|
|
|
|
|
char number[20];
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
scanf("%s",&number);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(!strcmp(number,arr[i].number))
|
|
|
|
|
{
|
|
|
|
|
strcpy(arr[i].name," ");
|
|
|
|
|
strcpy(arr[i].number," ");
|
|
|
|
|
strcpy(arr[i].beizhu," ");
|
|
|
|
|
arr[i].sex=' ';
|
|
|
|
|
arr[i].age=0;
|
|
|
|
|
save(arr,n);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!c==1)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void Modify(struct student*arr,int n)//xiugai
|
|
|
|
|
{
|
|
|
|
|
char number[20];
|
|
|
|
|
char password[10]={0};
|
|
|
|
|
int i;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺\n");
|
|
|
|
|
for(i = 0;i < 3;i++)
|
|
|
|
|
{
|
|
|
|
|
scanf("%s",password);
|
|
|
|
|
if(strcmp(password,"123456") == 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i == 3)
|
|
|
|
|
{printf("<EFBFBD>˳<EFBFBD>ϵͳ\n");}
|
|
|
|
|
else
|
|
|
|
|
int number;
|
|
|
|
|
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ\n");//enter xiugai
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>\n");
|
|
|
|
|
scanf("%d",&number);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{ int c;
|
|
|
|
|
if(!strcmp(number,arr[i].number))
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ ѧ<><D1A7> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
|
|
|
|
|
printf("%12s%12s%12c%12d%12s",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>Ϣ");
|
|
|
|
|
scanf("%s%s%c%d%s",&arr[i].number,&arr[i].name,&arr[i].sex,&arr[i].age,&arr[i].beizhu);
|
|
|
|
|
save(arr,n);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
if(!c==1)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
void Search(struct student*arr,int n)//chaxun
|
|
|
|
|
{
|
|
|
|
|
int i,select,c;
|
|
|
|
|
printf("*********ͨ<><CDA8>ѧ<EFBFBD>Ų<EFBFBD>ѯ*********\n");
|
|
|
|
|
printf("*********ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ*********\n");
|
|
|
|
|
printf("*********ͨ<><CDA8><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ѯ*********\n");
|
|
|
|
|
printf("*********ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ*********\n");
|
|
|
|
|
printf("**********<2A>˳<EFBFBD><CBB3><EFBFBD>ѯ**********\n");
|
|
|
|
|
scanf("%d",&select);
|
|
|
|
|
switch(select)
|
|
|
|
|
{
|
|
|
|
|
case 1://ѧ<><D1A7>hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
{
|
|
|
|
|
char num[20];
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",&num);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(!strcmp(num,arr[i].number))
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!c)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
case 2: //<2F><><EFBFBD><EFBFBD>hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
{
|
|
|
|
|
char num[20];
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",&num);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(!strcmp(num,arr[i].name))
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!c)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
case 3://<2F>Ա<EFBFBD>hhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
{
|
|
|
|
|
char ch;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:\n");
|
|
|
|
|
scanf("%c",&ch);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(ch==arr[i].sex)
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!c)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
case 4://<2F><><EFBFBD><EFBFBD>hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
{
|
|
|
|
|
char age;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%d",&age);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(age==arr[i].age)
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
|
|
|
|
|
c=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!c)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
} break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
|
|
|
|
|
int main()//zhuhanshu
|
|
|
|
|
{
|
|
|
|
|
struct student arr[N];
|
|
|
|
|
char password[10]={0};
|
|
|
|
|
int i,select;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺\n");
|
|
|
|
|
for(i = 0;i < 3;i++)
|
|
|
|
|
{
|
|
|
|
|
scanf("%s",password);
|
|
|
|
|
if(strcmp(password,"123456") == 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i == 3)
|
|
|
|
|
{printf("<EFBFBD>˳<EFBFBD>ϵͳ\n");}
|
|
|
|
|
else
|
|
|
|
|
int select;
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD>ɹ<EFBFBD>\n");//<2F><>ʼ
|
|
|
|
|
menu();
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%d",&select); //xuanze
|
|
|
|
|
while(select>0&&select<7)
|
|
|
|
|
{
|
|
|
|
|
switch(select)
|
|
|
|
|
{
|
|
|
|
|
case 1:Entry(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:Display(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 3: save(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 4:Delete(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 5:Modify(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 6:Search(arr,N);
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 7: exit(0); //<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ֵΪ7<CEAA><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|