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.

455 lines
7.8 KiB

6 years ago
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#define N 100
struct student
{
char no[9];
char name[25];
char sex[10];
int age;
char jiguan[25];
char xibie[25];
char zhuanye[25];
int ban;
}stu[N];
void menu()//<2F>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
{
int choice,w1;
void add();
void find();
void shanchu();
void change();
void tongji();
void read();
void input();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
do{
puts("\t*********************");
puts("\t <20><>ӭʹ<D3AD><CAB9>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ");
puts("\t 1,¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 2,<2C><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 3,ɾ<><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 4,<2C>޸<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 5,<2C><>ѧ<EFBFBD>Ż<EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 6,<2C><EFBFBD><E9BFB4><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
puts("\t 7,<2C>˳<EFBFBD>ϵͳ");
puts("\t**********************");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>");
scanf("%d,&choice");
if(choice<1||choice>8)
{
w1=1;
system("cls");
printf("<EFBFBD>˵<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>");
}
else w1=0;
} while(w1==1);
switch(choice)//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>IJ˵<C4B2>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
{
case 1:
add();
break;
case 2:
find();
break;
case 3:
shanchu();
break;
case 4:
change();
break;
case 5:
tongji();
break;
case 6:
read();
break;
case 7:
break;
default:exit(0);
}
}
int load()
{
FILE *fp;
int i;
if((fp=fopen("results.txt","rb"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD>򿪴<EFBFBD><EFBFBD><EFBFBD>");
return 0;
}
for(i=0;!feof(fp);i++)
fread(&stu[i],sizeof(struct student),1,fp);
fclose(fp);
return (i-1);
}
//<2F><><EFBFBD><EFBFBD><E6BAAF>
void save(int n)
{
int i;
FILE *fp;
if((fp=fopen("results.txt","wb"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD>򿪴<EFBFBD><EFBFBD><EFBFBD>");
}
for(i=0;i<n;i++)
fwrite(&stu[i],sizeof(struct student),1,fp);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void read()
{
int n,m;
n=load();
printf("ѧ<EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>Ա<EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tϵ<EFBFBD><EFBFBD>\tרҵ\t<EFBFBD>\t");
for(m=0;m<n;m++)
{
printf("\n%s",stu[m].no);
printf("\t%s",stu[m].name);
printf("\t%s",stu[m].sex);
printf("\t%d",stu[m].age);
printf("\t%s",stu[m].jiguan);
printf("\t%s",stu[m].xibie);
printf("\t%s",stu[m].zhuanye);
printf("\t%d",stu[m].ban);
}
{
int xz,choice;//ѡ<>񷵻ػ<F1B7B5BB><D8BB><EFBFBD><EFBFBD>˳<EFBFBD>ϵͳ<CFB5>ı<EFBFBD><C4B1><EFBFBD>
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>\n");
}
else xz=0;
} while(xz==1);
switch(choice)
{
case 1:
menu();
break;//<2F><><EFBFBD>ò˵<C3B2><CBB5><EFBFBD><EFBFBD><EFBFBD>
case 2:
exit(0);
break;//<2F>˳<EFBFBD>ϵͳ
}
}
}
//¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
void add()
{
FILE *fp;
int n,i,m;
n=load();
if((fp=fopen("results.txt","wb"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD>򿪴<EFBFBD><EFBFBD><EFBFBD>\n");
exit(0);
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
scanf("%d",&m);
for(i=0;i<m;i++)
{
printf("\nѧ<EFBFBD><EFBFBD>:");
scanf("%sm",stu[n+i].no);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",stu[n+i].name);
printf("<EFBFBD>Ա<EFBFBD>:");
scanf("%s",stu[n+i].sex);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&stu[n+i].age);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",stu[n+i].jiguan);
printf("ϵ<EFBFBD><EFBFBD>:");
scanf("%s",stu[n+i].xibie);
printf("רҵ:");
scanf("%s",stu[n+i].zhuanye);
printf("<EFBFBD>༶:");
scanf("%d",&stu[n+i].ban);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
save(n+m);
}
for(i=0;i<m;i++)
fwrite(&stu[i],sizeof(struct student),1,fp);
for(i=0;i<m;i++)
fwrite(&stu[i],sizeof(struct student),1,fp);
fclose(fp);
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu();
break;
case 2:
exit(0);
break;
}
}
}
//<2F><><EFBFBD>Һ<EFBFBD><D2BA><EFBFBD>
void find()
{
int menu();
int n,i;
char m[9];
n=load();
printf("\t\t<EFBFBD><EFBFBD>ӭʹ<EFBFBD><EFBFBD>ѧ<EFBFBD>Ų<EFBFBD><EFBFBD>ҹ<EFBFBD><EFBFBD><EFBFBD>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%s",&m);
for(i=0;i<n;i++)
{
if(!strcmp(stu[i].no,m))
{
printf("ѧ<EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>Ա<EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tϵ<EFBFBD><EFBFBD>\tרҵ\t<EFBFBD>\n");
printf("%s",stu[i].no);
printf("\t%s",stu[i].name);
printf("\t%s",stu[i].sex);
printf("\t%d",stu[i].age);
printf("\t%s",stu[i].jiguan);
printf("\t%s",stu[i].xibie);
printf("\t%s",stu[i].zhuanye);
printf("\t%d\n",stu[i].ban);
}
}
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>\n");
}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu();
break;
case 2:
exit(0);
break;
}
}
}
//<2F>޸ĺ<DEB8><C4BA><EFBFBD>
void change()
{
int n,i,j;
char m[9];
n=load();
printf("<EFBFBD><EFBFBD>ӭʹ<EFBFBD><EFBFBD><EFBFBD>޸Ĺ<EFBFBD><EFBFBD><EFBFBD>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%s",&m);
for(i=0;i<n;i++)
{
if(!strcmp(stu[i].no,m))
{
printf("<EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD>Ŀ:\n1)ѧ<><D1A7>2)<29><><EFBFBD><EFBFBD>3)<29>Ա<EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5)<29><><EFBFBD><EFBFBD>6)ϵ<><CFB5>7)רҵ8)<29>\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&j);
switch(j)
{
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%s",stu[i].no);
break;
case 2:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",stu[i].name);
break;
case 3:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:");
scanf("%s",stu[i].sex);
break;
case 4:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&stu[i].age);
break;
case 5:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",stu[i].jiguan);
break;
case 6:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>:");
scanf("%s",stu[i].xibie);
break;
case 7:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD><EFBFBD>רҵ:");
scanf("%s",stu[i].zhuanye);
break;
case 8:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD><EFBFBD>İ༶:");
scanf("%d",&stu[i].ban);
break;
default:
printf("ѡ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>\n");
int getch();
change();
break;
}
save(n);
}
}
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>\n");
}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu();
break;
case 2:
exit(0);
break;
}
}
}
//ͳ<>ƺ<EFBFBD><C6BA><EFBFBD>
void tongji()
{
int k,i,n;
struct student t;
system("cls");
printf("ѧ<EFBFBD><EFBFBD> רҵ <20><><EFBFBD><EFBFBD>\n");
for(k=0;k<n-1;k++)
{
for(i=0;i<n-k-1;i++)
{
if(stu[i].no>stu[i+1].no)
t=stu[i];
stu[i]=stu[i+1];
stu[i+1]=t;
}
}
for(i=0;i<n;i++)
{
if(stu[i].no!=0)
printf("%s %s %s",stu[i].no,stu[i].zhuanye,stu[i].jiguan);
}
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD>ز˵<D8B2><CBB5><EFBFBD><EFBFBD><EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>\n");
}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu();
break;
case 2:
exit(0);
break;
}
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void shanchu()
{
int n,i,j;
char m[9];
n=load();
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>");
scanf("%s",&m);
for(i=0;i<n;i++)
if(!strcmp(stu[i].no,m))
{
for(j=0;j<n-1;j++)
{
strcpy(stu[j].no,stu[j+1].no);
strcpy(stu[j].name,stu[j+1].name);
stu[j].age=stu[j+1].age;
strcpy(stu[j].jiguan,stu[j+1].jiguan);
strcpy(stu[j].xibie,stu[j+1].xibie);
strcpy(stu[j].zhuanye,stu[j+1].zhuanye);
strcpy(stu[j].sex,stu[j+1].sex);
stu[j].ban=stu[j+1].ban;
}
save(n-1);
}
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>;2-<2D>˳<EFBFBD>ϵͳ\n");
scanf("%d",&choice);
if(choice<1||choice>2)
{
xz=1;system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>\n");
}
else xz=0;
} while(xz==1);
switch(choice)
{
case 1:
menu();
break;
case 2:
exit(0);
break;
}
}
}
int main()
{
menu();
}