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.
bjglxt/班级档案管理系统最新版本.cpp

271 lines
7.3 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define file "d:\\student.txt" //Ĭ<>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>d<EFBFBD><64>
#include<conio.h>
struct student{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
char number[20];
char name[20];
char sex[20];
char age[20];
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>Ϣϵͳ +");//ExitFuction
printf("\n ++++++++++++++++++++++++++++++++++++++++++++++++\n");
}
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
void Entry(struct student arr[],int n)//¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
{
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 %s %s %s",&arr[i].number,&arr[i].name,&arr[i].sex,&arr[i].age,&arr[i].beizhu);
}
}
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
int mima()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBAAF>
{
char pwd[]="123456";
char Ipt[20];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: \n");
scanf("%s",Ipt);
if(strcmp(pwd,Ipt)!=0)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
return 0;
}
else
return 1;
}
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
void Display(struct student arr[],int n)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
{
int i;
printf("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
for(i=0;i<n;i++)
{
printf("%-12s%-10s%-8s%-8s%-12s\n",arr[i].number,arr[i].name,arr[i].sex,arr[i].age,arr[i].beizhu);
}
}
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
void save(struct student arr[],int n)//<2F><><EFBFBD><EFBFBD><EFBFBD><E6BAAF>
{
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)//<2F><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int i,c,j;
c=0;
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))
{
for(j=i;j<n;j++)
arr[j]=arr[j+1]; //ֱ<>ӰѺ<D3B0><D1BA><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
strcpy(arr[n-1].name," ");
strcpy(arr[n-1].number," ");
strcpy(arr[n-1].beizhu," ");
strcpy(arr[n-1].sex," ");
strcpy(arr[n-1].age," ");
save(arr,n);
c=1;
}
}
if(!c==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD>޴<EFBFBD><EFBFBD><EFBFBD>\n");
}
}
/*hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh*/
void Modify(struct student*arr,int n)//<2F><><EFBFBD><EFBFBD><EFBFBD>޸ĺ<DEB8><C4BA><EFBFBD>
{
int i;
int daiti;
char number[20];
daiti=mima();
if(daiti)
{
printf("<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>ϵͳ\n");
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><EFBFBD><EFBFBD>Ϣ");
scanf("%s %s %s %s %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)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
{
int i,select,c;
c=0;
printf("*********1:ͨ<><CDA8>ѧ<EFBFBD>Ų<EFBFBD>ѯ*********\n");
printf("*********2:ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ*********\n");
printf("*********3:ͨ<><CDA8><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ѯ*********\n");
printf("*********4:ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ*********\n");
printf("*********5:<3A>˳<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("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
printf("%-12s%-10s%-8s%-8s%-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("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
printf("%-12s%-10s%-8s%-8s%-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[10];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:\n");
scanf("%s",&ch);
for(i=0;i<n;i++)
{
if(!strcmp(ch,arr[i].sex))
{
printf("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
printf("%-12s%-10s%-8s%-8s%-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[20];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s",&age);
for(i=0;i<n;i++)
{
if(!strcmp(age,arr[i].age))
{
printf("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע\n");
printf("%-12s%-10s%-8s%-8s%-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()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int N,daiti,i,select;
struct student arr[100];
char password[10];
daiti=mima();
if(daiti)
{
menu();
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
scanf("%d",&select);
if(!(select>0&&select<7))
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>O(<28><>_<EFBFBD><5F>)Oлл");
}
else
{
while(select>0&&select<7)
{
switch(select)
{
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&N);
Entry(arr,N); system("pause");system("cls");menu();break;
case 2:Display(arr,N); system("pause");system("cls");menu();break;
case 3: save(arr,N); system("pause");system("cls");menu();break;
case 4:Delete(arr,N); system("pause");system("cls");menu();break;
case 5:Modify(arr,N); system("pause");system("cls");menu();break;
case 6:Search(arr,N); system("pause");system("cls");menu();break;
case 7: exit(0); //<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ֵΪ7<CEAA><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
scanf("%d",&select);
system("cls");
}
}
return 0;
}
}