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.
283 lines
6.9 KiB
283 lines
6.9 KiB
#include<stdio.h>
|
|
#include<string.h>
|
|
#include<stdlib.h>
|
|
struct student_info
|
|
{
|
|
int id;
|
|
char name[20];
|
|
float cscore;
|
|
};
|
|
struct student students[50];
|
|
int count=0;
|
|
printf("****************???????***************");
|
|
printf("* *");
|
|
printf("** 1.???? **");
|
|
printf("** 2.???? **");
|
|
printf("** 3.???? **");
|
|
printf("** 4.???????? **");
|
|
printf("** 5.?????,??? **");
|
|
printf("** 6.????????? **");
|
|
printf("****************~~~~~~~~~~~~~~***************");
|
|
int main()
|
|
{
|
|
int n;
|
|
system("cls")
|
|
char name[20];
|
|
int i=0;
|
|
FILE *fp;
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
for(i=0;i<50;i++)
|
|
{
|
|
fprintf(fp,"%d %s %d",students[i].id,students[i].name,students[i].cscore);
|
|
}
|
|
do
|
|
{
|
|
printf("?????????:1.?? 2.?? 3.?? 4.????????\n5.?????,??? 6.????????? 7.??\n");
|
|
scanf("%d",&n);
|
|
switch(n)
|
|
{
|
|
case 1:
|
|
printf("???????????");
|
|
scanf("%s",students[i].name)
|
|
search_student(students,name);
|
|
break;
|
|
case 2:
|
|
printf("??0???????????????\n");
|
|
do
|
|
{
|
|
printf("???????????:");
|
|
scanf("%d",&students[i],id);
|
|
printf("???????????:");
|
|
scanf("%s",students[i].name);
|
|
printf("???????????");
|
|
scanf("%f",&students[i].csore);
|
|
if(students[i].id!=0)
|
|
fprintf(fp,"%d %s %s",students[i].id,students[i].name,students[i].cscore);
|
|
}while(students[i].id!=0);
|
|
fclose(fp);
|
|
break;
|
|
case 3:
|
|
printf("???????????:");
|
|
scanf("%d",&students[i].id);
|
|
printf("???????????:");
|
|
scanf("%s",students[i].name);
|
|
printf("???????????:");
|
|
scanf("%d",&students[i].cscore);
|
|
modify_student(students,id,name,cscore);
|
|
break;
|
|
case 4:
|
|
system("cls");
|
|
int i,j
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
while(fscanf(fp,"%d %s %d",&students[i].id,&students[i].name,&students[i].cscore)!=EOF)
|
|
{
|
|
i++;
|
|
}
|
|
fclose(fp);
|
|
printf("90????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=90)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("80????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=80&&students[j].cscore<90)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("70????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=70&&students[j].cscore<80)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("60????:")
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=60&&students[j].cscore<70)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("50????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=50&&students[j].cscore<60)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("40????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=40&&students[j].cscore<50)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("30????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=30&&students[j].cscore<40)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("20????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=20&&students[j].cscore<30)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("10????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=10&&students[j].cscore<20)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
printf("0????:");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore>=0&&students[j].cscore<10)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
printf("\n");
|
|
}
|
|
for(j=0;j<i;j++)
|
|
if(students[j].cscore<0)
|
|
break;
|
|
|
|
case 5:
|
|
system("cls");
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
while(fscanf(fp,"%d %s %d",&students[i].id,&students[i].name,&students[i].cscore)!=EOF)
|
|
{
|
|
i++;
|
|
}
|
|
fclose(fp);
|
|
int max,min,j;
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(students[j].cscore<students)
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
system("cls");
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
while(fscanf(fp,"%d %s %d",&students[i].id,&students[i].name,&students[i].cscore)!=EOF)
|
|
{
|
|
i++;
|
|
}
|
|
fclose(fp);
|
|
strcut student temp;
|
|
for(j=0;j<i-1;j++)
|
|
{
|
|
for(u=0;u<i-1-j;u++)
|
|
if(students[u].cscore<students[u+1].cscore)
|
|
temp=students[u];
|
|
students[u]=students[u+1];
|
|
students[u+1]=temp;
|
|
}
|
|
for(j=0;j<i;j++)
|
|
printf("%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
break;
|
|
|
|
int serach_student(struct student_info students[],char *name)
|
|
{
|
|
system("cls");
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
while(fscanf(fp,"%d %s %d",&students[i].id,&students[i].name,&students[i].cscore)!=EOF)
|
|
{
|
|
i++;
|
|
}
|
|
fclose(fp);
|
|
int i,flag=0;
|
|
if(i==0)
|
|
{
|
|
printf("??????!\n");
|
|
return -1;
|
|
}
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(strcmp(name,students[j].name)==0)
|
|
flag=1;
|
|
if(flag)
|
|
{
|
|
printf("??: %s ??:%s c????:%f",students[j].id,students[j].name,students[j].cscore);
|
|
return j;
|
|
}
|
|
}
|
|
printf("????????!");
|
|
return -1;
|
|
}
|
|
|
|
int modify_student(struct student_info students[],int idcard,char *names,int cscores)
|
|
{
|
|
system("cls");
|
|
int n,i,j;
|
|
if((fp=fopen("a.txt","w+"))==NULL)
|
|
{
|
|
printf("can not open the file!");
|
|
exit(0);
|
|
}
|
|
while(fscanf(fp,"%d %s %d",&students[i].id,&students[i].name,&students[i].cscore)!=EOF)
|
|
{
|
|
i++;
|
|
}
|
|
printf("1.??????????? 2.??????????? ???:\n");
|
|
scanf("%d",&n);
|
|
if(n==1)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(strcmp(names,students[j].name)==0)
|
|
students[j].cscore=cscores;
|
|
}
|
|
}
|
|
if(n==2)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(idcard==students[j].id)
|
|
students[j].cscore=cscores;
|
|
}
|
|
}
|
|
fp=fopen("a.txt","w");
|
|
for(j=0;j<i;j++)
|
|
{
|
|
fprintf(fp,"%d %s %d",students[j].id,students[j].name,students[j].cscore);
|
|
}
|
|
fclose(fp);
|
|
}
|