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.

286 lines
4.9 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 meau();
int n,i;
char m[9];
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].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>,<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>޸ĺ<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,<2C><><EFBFBD><EFBFBD>3,<2C>Ա<EFBFBD>4,<2C><><EFBFBD><EFBFBD>5,<2C><><EFBFBD><EFBFBD>6,ϵ<><CFB5>7,רҵ")
}
}
}