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.

426 lines
7.4 KiB

6 years ago
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#define N 100
struct student
{
char id[10];
char name[25];
char sex[10];
int age;
char jiguan[25];
char xibie[25];
char zhuanye[25];
int ban;
}stu[N];
void menu()
{
int choice,w1;
void add();void find();void shanchu();void change();void tongji();void read();void input();
do
{
puts("\t--------------------------------------------------------");
puts("\t| <20><>ӭʹ<D3AD><CAB9>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ |");
puts("\t|------------------------------------------------------|");
puts("\t| 1.¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 2.<2E><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 3.ɾ<><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 4.<2E>޸<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 5.<2E><>ѧ<EFBFBD>Ż<EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 6.<2E><EFBFBD><E9BFB4><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |");
puts("\t| 7.<2E>˳<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>\n");}
else w1=0;
}while(w1==1);
switch (choice)
{
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);
}
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);
fclose(fp);
}
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].id);
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;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
void add()
{
FILE *fp;
int i,n,m;
n=load();
if ((fp=fopen("results.txt","wb"))==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD>򿪴<EFBFBD><EFBFBD><EFBFBD>!\n");
exit(1);
}
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("%s",stu[n+i].id);
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);
fclose(fp);
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
void find()
{
int meau();
int n,i;
char m[10];
n=load();
printf("\t\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].id,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].id);
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><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
void change()
{
int n,i,j;
char m[10];
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].id,m))
{
printf("<EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>\n1)ѧ<><D1A7>2)<29><><EFBFBD><EFBFBD>3)<29>Ա<EFBFBD>4)<29><><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].id);
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><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
void tongji_1()
{
int n,i,sum=0;
char m[10];
n=load();
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͳ<EFBFBD>Ƶ<EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%s",&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");
for (i=0;i<n;i++)
if (!strcmp(stu[i].id,m))
{
printf("%s",stu[i].id);
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);
sum++;
printf("%sѧ<73>ŵ<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",m,sum);}
}
void tongji_2()
{
int n,i,sum=0;
char m[25];
n=load();
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫͳ<EFBFBD>Ƶ<EFBFBD>רҵ:");
scanf("%s",&m);
printf("ѧ<EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD>Ա<EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tרҵ\t<EFBFBD>\n");
for (i=0;i<n;i++)
if (!strcmp(m,stu[i].zhuanye))
{
printf("%s",stu[i].id);
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);
sum++;
printf("%sרҵ<D7A8><D2B5>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>/n",m,sum);}
}
void tongji()
{
int n,m;
n=load();
printf("<EFBFBD><EFBFBD>ӭʹ<EFBFBD><EFBFBD>ͳ<EFBFBD>ƹ<EFBFBD><EFBFBD><EFBFBD>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>:1) ѧ<><D1A7>\t2) רҵ\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&m);
switch (m)
{
case 1:
tongji_1();
break;
case 2:
tongji_2();
break;
default :
printf("ѡ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>\n");
int getch();
tongji();
break;
}
{
int xz,choice;
do
{
printf("\n1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
void shanchu()
{
int n,i,j;
char m[10];
n=load();
printf("<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].id,m))
{
for (j=i;j<n-1;j++)
{
strcpy(stu[j].id,stu[j+1].id);
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><CBB5><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><EFBFBD><EFBFBD>\n");}
else xz=0;
}while(xz==1);
switch(choice)
{
case 1:
menu(); break;
case 2:
exit(0); break;
}
}
}
int main()
{
menu();
}