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.

227 lines
4.8 KiB

6 years ago
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
{ long int num;
char name[20];
int age;
char sex[4];
char p[15];
}stu[100];
int n=0;
FILE *fp;
struct student *p;
void lr();
void ll();
void cx();
void px();
void xg();
void sc();
void bc();
void bc();
void main()
{
int z;
printf("/<2F><>ӭʹ<D3AD><CAB9>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ϵͳ/\n");
do
{ printf(" <20><><EFBFBD>˵<EFBFBD> \n");
printf(" [1]----¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [2]----<2D><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [3]----<2D><>ѯѧ<D1AF><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [4]----<2D><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [5]----ɾ<><C9BE>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [6]----<2D>޸<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [7]----<2D><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ \n");
printf(" [0]----<2D>˳<EFBFBD>ϵͳ \n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d", &z);
switch(z)
{ case 0 : break;
case 1 :lr();break;
case 2 :ll();break;
case 3 :cx();break;
case 4 :px();break;
case 5 :sc();break;
case 6 :xg();break;
case 7 :bc();break;
default:printf("\n<EFBFBD><EFBFBD>Чѡ<EFBFBD><EFBFBD>");
}
}
while(z!= 0);
}
void lr()/*¼<><EFBFBD><EBBAAF>*/
{ int y;
if(n==0) p=stu;
do
{ printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld",&p->num);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",p->name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&p->age);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>:");
scanf("%s",p->sex);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>ĵ绰:");
scanf("%s",p->p);
n++; p++;
printf("\n1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n0.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&y);
}
while(y==1);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!<21><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",n);
}
void ll()/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{ printf("\nѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20>\n");
char ch;
if((fp=fopen("student.txt","r"))==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>");
exit(0);
}
ch=fgetc(fp);
while(ch!=EOF)
{
printf("%c",ch);
ch=fgetc(fp);
}
fclose(fp);
}
void cx()/*<2A><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>*/
{ int c;
int w,i,j=0;
char name[20];
if(n!=0)
{ do{ printf("\n");
printf(" <20><>ѧ<EFBFBD>Ų<EFBFBD>ѯ <20>밴 1 \n");
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ <20>밴 2 \n");
printf(" ȡ<><C8A1> <20>밴 0 \n");
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
scanf("%d", &c);
switch(c)
{ case 0:break;
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%ld", &w);
printf("\n");
for(i=0;i<n;i++)
if(stu[i].num==w)
{ printf("\nѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20>\n");/*<2A><>ʾ<EFBFBD><CABE>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>1*/
printf("%ld %s %d %s %s\n",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].p);
j=1;
}
if(j==0)
printf("<EFBFBD><EFBFBD>ʾ<>и<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>˶ԣ<CBB6>");break;
case 2:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s", name);
printf("\n");
for(i=0;i<n;i++)
if(strcmp(name,stu[i].name)==0)
{ printf("\nѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20>\n");/*<2A><>ʾ<EFBFBD><CABE>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>2*/
j=1;
printf("%ld %s %d %s %s\n",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].p);
}
if(j==0)
printf("<EFBFBD><EFBFBD>ʾ<>и<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>˶ԣ<CBB6>");break;
default:
printf("\n<EFBFBD><EFBFBD>ʾ:<3A><>Чѡ<D0A7><D1A1>!");break;
}
} while(c!= 0);
} else printf("<EFBFBD><EFBFBD>ʾ:<3A><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
return;
}
void px()/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{ int i,j;
struct student t[100];
for(i=0;i<n;i++)
{ for(j=0;j<n-1-i;j++)
{if(stu[j].num>stu[j+1].num)
{t[i]=stu[j];
stu[j]=stu[j+1];
stu[j+1]=t[i];
}
}
}
for(i=0;i<n;i++)
{ printf("%ld %s %d %s %s\n",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].p);
}
}
void xg()/*<2A>޸ĺ<DEB8><C4BA><EFBFBD>*/
{ long int num;
int i,j,c;
if(n!=0)
{ printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%ld", &num);
printf("\n");
for(i=0;i<n;i++)
if(stu[i].num==num)
j=i;
do{
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>\n");
printf(" <20><><EFBFBD><EFBFBD> <20>밴 1 \n");
printf(" <20><><EFBFBD><EFBFBD> <20>밴 2 \n");
printf(" <20>Ա<EFBFBD> <20>밴 3 \n");
printf(" ѧ<><D1A7> <20>밴 4 \n");
printf(" <20><20>밴 5 \n");
printf(" ȡ<><C8A1> <20>밴 0 \n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d", &c);
printf("\n");
switch(c)
{ case 0:break;
case 1:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",stu[j].name);break;
case 2:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&stu[j].age);break;
case 3:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",stu[j].sex);break;
case 4:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%ld",&stu[j].num);break;
case 5:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ绰<EFBFBD><EFBFBD>");
scanf("%s",stu[j].p);break;
default:
printf("\n<EFBFBD><EFBFBD>Чѡ<EFBFBD><EFBFBD>!");
break;
}
} while(c!= 0);
} else printf("<EFBFBD><EFBFBD>ʾ:<3A><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
}
void sc()/*ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?*/
{ long int num;
int i,j,e;
if(n!=0)
{ printf("ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20>\n");/*<2A><>ʾɾ<CABE><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
for(i=0;i<n;i++)
printf("%ld %s %d %s %s\n",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].p);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%ld", &num);
printf("\n");
for(i=0;i<n;i++)
if(num==stu[i].num)
j=i;
if(j!=(n-1))
{ for(e=i-1;e<n;e++,j++)
{ stu[j].num=stu[j+1].num;
strcpy(stu[j].name,stu[j+1].name);
strcpy(stu[j].sex,stu[j+1].sex);
stu[j].age=stu[j+1].age;
strcpy(stu[j].p,stu[j+1].p);
n--;
p--;
}
}else {n--;
p--;}
printf("<EFBFBD><EFBFBD>ʾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>");
}else printf("<EFBFBD><EFBFBD>ʾ:<3A><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
}
void bc()/*<2A><><EFBFBD><EFBFBD><E6BAAF>*/
{ int i;
FILE *fp;
fp=fopen("student.txt","wb+");
for(i=0;i<n;i++)
{
fprintf(fp,"%ld %s %d %s %s \n",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].p);
}
fclose(fp);
}