|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#define N 2
|
|
|
|
|
struct student
|
|
|
|
|
{
|
|
|
|
|
char name[10];
|
|
|
|
|
char no[100];
|
|
|
|
|
int sex;
|
|
|
|
|
int age;
|
|
|
|
|
char bnote[100];
|
|
|
|
|
};
|
|
|
|
|
void print(bool menu)//<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
{
|
|
|
|
|
if (!menu)
|
|
|
|
|
{
|
|
|
|
|
printf(" \t \t \t (<28><>ӭʹ<D3AD>ñ<EFBFBD><C3B1>༶<EFBFBD><E0BCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ)\t\t\t\t\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><> <20><>ӭ<EFBFBD><D3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>ϵͳ <20><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>*<2A><>\n\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD>:1,Ů:2\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ¼<EFBFBD><EFBFBD> ,press 1\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʾ ,press 2\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,press 3\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣɾ<EFBFBD><EFBFBD> ,press 4\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD> ,press 5\n");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ѯ ,press 6\n");
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD>˳<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣϵͳ ,press 7\n");
|
|
|
|
|
}
|
|
|
|
|
bool Check(char pas[6])//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char ch;
|
|
|
|
|
char a[7]={" "};
|
|
|
|
|
int i = 0;
|
|
|
|
|
if ((fp=fopen("D:\\1.txt","r"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
ch=fgetc(fp);
|
|
|
|
|
while (ch!=EOF&&i<6)
|
|
|
|
|
{
|
|
|
|
|
a[i] = ch;
|
|
|
|
|
ch=fgetc(fp);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
a[6] = '\0';
|
|
|
|
|
if (!strcmp(pas,a))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
void GetInfo(struct student *arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC>
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("D:\\student.txt","w");
|
|
|
|
|
for (int i = 0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",arr[i].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&arr[i].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:");
|
|
|
|
|
scanf("%d",&arr[i].sex);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&arr[i].age);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ע:");
|
|
|
|
|
scanf("%s",&arr[i].bnote);
|
|
|
|
|
}
|
|
|
|
|
for(int i=0;i<2;i++)
|
|
|
|
|
{
|
|
|
|
|
fprintf(fp,"%12s%12s%12d%12d%12s\n",arr[i].name,arr[i].no,arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
void Display(struct student* arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("D:\\student.txt","r");
|
|
|
|
|
printf("ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ: <20><><EFBFBD><EFBFBD> ѧ<><D1A7> <20>Ա<EFBFBD>(1<><31>/2Ů) <20><><EFBFBD><EFBFBD> <20><>ע\n");
|
|
|
|
|
for (int i = 0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
fscanf(fp,"%12s%12s%12d%12d%12s\n",&arr[i].name,&arr[i].no,&arr[i].sex,&arr[i].age,&arr[i].bnote);
|
|
|
|
|
printf("%12s%12s%12d%12d%12s\n",arr[i].name,arr[i].no,arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Save(struct student* arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>棬<EFBFBD><E6A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c:\\student.txt
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp= fopen("D:\\student.txt","w+");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
for(int i=0;i<2;i++)
|
|
|
|
|
{
|
|
|
|
|
fprintf(fp,"%12s%12s%12d%12d%12s\n",arr[i].name,arr[i].no,arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Modfiy(struct student* arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
char number[100];
|
|
|
|
|
bool flag=false;
|
|
|
|
|
char pass[6];
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",pass);
|
|
|
|
|
if (Check(pass))
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",number);
|
|
|
|
|
for (int i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(number,arr[i].no))
|
|
|
|
|
{
|
|
|
|
|
printf("infor: name no sex age note\n");
|
|
|
|
|
printf("please input information:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&arr[i].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&arr[i].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:");
|
|
|
|
|
scanf("%d",&arr[i].sex);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&arr[i].age);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ע:");
|
|
|
|
|
scanf("%s",&arr[i].bnote);
|
|
|
|
|
Save(arr,n);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag == false)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!:\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Delete(struct student* arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣɾ<CFA2><C9BE>
|
|
|
|
|
{
|
|
|
|
|
char number[100];
|
|
|
|
|
bool flag=false;
|
|
|
|
|
printf("Delete information:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",number);
|
|
|
|
|
for (int i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(number,arr[i].no))
|
|
|
|
|
{
|
|
|
|
|
strcpy(arr[i].name," ");
|
|
|
|
|
strcpy(arr[i].no," ");
|
|
|
|
|
strcpy(arr[i].bnote," ");
|
|
|
|
|
arr[i].sex = ' ';
|
|
|
|
|
arr[i].age =0;
|
|
|
|
|
Save(arr,n);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag == false)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!:\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Search(struct student* arr,int n)//ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ѯ
|
|
|
|
|
{
|
|
|
|
|
int temp,i;
|
|
|
|
|
bool flag=false;
|
|
|
|
|
printf("--------------ͨ<><CDA8>ѧ<EFBFBD>Ų<EFBFBD>ѯ,press 1-------------\n");
|
|
|
|
|
printf("---------------ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ,press 2-----------\n");
|
|
|
|
|
printf("---------------ͨ<><CDA8><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ѯ,press 3------------\n");
|
|
|
|
|
printf("---------------ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ,press 4------------\n");
|
|
|
|
|
printf("---------------<2D>˳<EFBFBD>,press 5 ------------\n");
|
|
|
|
|
scanf("%d",&temp);
|
|
|
|
|
switch (temp)
|
|
|
|
|
{
|
|
|
|
|
case 1://<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD>Ų<EFBFBD>ѯ
|
|
|
|
|
{
|
|
|
|
|
char num[100];
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
for ( i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(num,arr[i].no))
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
|
|
|
|
|
arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>ѯ
|
|
|
|
|
{
|
|
|
|
|
char num[10];
|
|
|
|
|
printf("please input name:\n");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
for ( i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(num,arr[i].name))
|
|
|
|
|
{
|
|
|
|
|
printf("%-12s%-12s%-12c%-12d%-12s",arr[i].name,arr[i].no,arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3://<2F><><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ѯ
|
|
|
|
|
{
|
|
|
|
|
char ch;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:\n");
|
|
|
|
|
//scanf("%c",&ch);
|
|
|
|
|
ch = getch();
|
|
|
|
|
for ( i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (ch == arr[i].sex)
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
|
|
|
|
|
arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
printf("t<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ
|
|
|
|
|
{
|
|
|
|
|
char num_age;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%d",&num_age);
|
|
|
|
|
for ( i =0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if (num_age == arr[i].age)
|
|
|
|
|
{
|
|
|
|
|
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
|
|
|
|
|
arr[i].sex,arr[i].age,arr[i].bnote);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
struct student arr[N];
|
|
|
|
|
char ps[6];
|
|
|
|
|
bool flag =false;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",ps);
|
|
|
|
|
flag = Check(ps);
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
int select;
|
|
|
|
|
print(false);
|
|
|
|
|
scanf("%d",&select);
|
|
|
|
|
while (0<select && select <7 )
|
|
|
|
|
{
|
|
|
|
|
switch (select)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
GetInfo(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
|
|
Display(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
Save(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
Delete(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
Modfiy(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
Search(arr,N);
|
|
|
|
|
print(true);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%d",&select);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|