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.

221 lines
4.0 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;
}
}
}