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.

291 lines
6.6 KiB

6 years ago
#include<stdio.h> //<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include<stdlib.h> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEBAAF><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><E4BAAF>
#include<string.h> //<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include <time.h> //<2F>õ<EFBFBD><C3B5><EFBFBD>time<6D><65><EFBFBD><EFBFBD>
int main()
{
int num=0;
while(1)
{
system("cls");
load();
printf("|----<2D><EFBFBD><E8B3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ----\n");
printf("\n ----------------------\n");
printf("| [1] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC> |\n");
printf("| [2] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ |\n");
printf("| [3] <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ |\n");
printf("| [4] <20>޸<EFBFBD><DEB8><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD> |\n");
printf("| [5] <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |\n");
printf("| [6] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |\n");
printf("| [7] <20>˳<EFBFBD>ϵͳ |\n");
printf(" ----------------------\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>еIJ<EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&num);
switch(num)//<2F>˵<EFBFBD>
{
case 1 : info_sign();break;//¼<><C2BC>
case 2 : info_show();break;//<2F><>ʾ
case 3 : info_find();break;//<2F><><EFBFBD><EFBFBD>
case 4 : grade_modify();break;//<2F>޸<EFBFBD>
case 5 : find_order();break;
case 6 : result_sort();break;
case 7 : exit(0);
}
}
}
struct node{
int id;//<2F><><EFBFBD><EFBFBD>
char name[20];//<2F><><EFBFBD><EFBFBD>
double score[11];//<2F>ɼ<EFBFBD>
double sum;//ƽ<><C6BD><EFBFBD><EFBFBD>
}st[100],s;
int snum=0;
int load() /********************************************<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ڴ<EFBFBD> *************************************/
{
snum=0;
FILE *fp; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ָ<EFBFBD><D6B8>
fp=fopen("info.txt","r"); //<2F>Զ<EFBFBD><D4B6>ķ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>info.dat<61>ļ<EFBFBD><C4BC><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
else{
while(!feof(fp)){//<2F><><EFBFBD><EFBFBD> <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
fread(&st[snum++],sizeof(struct node),1,fp); //snum<75>Dz<EFBFBD><C7B2><EFBFBD>ѡ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>һ<EFBFBD>Ρ<EFBFBD>
}
}
if(snum>0)
snum--;
else snum=0;
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d\n",snum);
return 0;
}
int save() /**********************************<2A><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD>******************************************/
{
FILE *fp;
int i,t=0;
fp=fopen("info.txt","w");//<2F><>д<EFBFBD>ķ<EFBFBD>ʽ<EFBFBD>򿪲<EFBFBD><F2BFAAB2><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϣ<EFBFBD>ļ<EFBFBD>
for(i=0;i<snum;i++){
fwrite(&st[i],sizeof(struct node),1,fp);
//<2F><><EFBFBD>ν<EFBFBD><CEBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>st<73><EFBFBD><E1B9B9>
}
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
//printf("%d\n",snum);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>Ϳγ<CDBF><CEB3><EFBFBD>Ŀ
return 0;
}
int info_sign() /*************************<2A><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϣ *********************/
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d\n",snum);
int i;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&st[snum].id);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",st[snum].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʮλ<EFBFBD><EFBFBD>ί<EFBFBD>ɼ<EFBFBD>:\n");
st[snum].sum=0;
double mi=0xffffff,ma=0;
for( i=0;i<10;i++)
{
scanf("%lf",&st[snum].score[i]);
if(mi>st[snum].score[i])
{
mi=st[snum].score[i];
}
if(ma<st[snum].score[i])
{
ma=st[snum].score[i];
}
st[snum].sum+=st[snum].score[i];
}
st[snum].sum=st[snum].sum-mi-ma;
st[snum].sum/=8;//<2F><>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
snum++;
save();//<2F><><EFBFBD>ڽṹ<DABD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>±<EFBFBD><C2B1><EFBFBD><E6BAAF>
getchar();getchar();
}
int info_show() //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{ int i;
for(i=0;i<snum;i++)
{
printf("\n---------------------------------------------------------------------------------------------\n");
printf("| <20><><EFBFBD><EFBFBD>:%04d | <20><><EFBFBD><EFBFBD>:%s | ƽ<><C6BD><EFBFBD><EFBFBD>%.2f |\n",st[i].id,st[i].name,st[i].sum);
int j;
printf("|ʮλ<CAAE><CEBB>ί<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>");
for(j=0;j<10;j++)
{
printf("[%d]%4.2f ",j+1,st[i].score[j]);
}
printf("\n---------------------------------------------------------------------------------------------\n");
}
getchar();
getchar();
return 0;
}
int info_find() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{
int i;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
int k;
scanf("%d",&k);
for(i=0;i<snum;i++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>course[]<5D><><EFBFBD>Ҷ<EFBFBD>Ӧ<EFBFBD><D3A6> <20>γ<EFBFBD>id
{
if(st[i].id==k)//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf(" <20><><EFBFBD><EFBFBD>:%04d <20><><EFBFBD><EFBFBD>:%s :ƽ<><C6BD><EFBFBD><EFBFBD>%.2f \n",st[i].id,st[i].name,st[i].sum);
int j;
printf("ʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>ɼ<EFBFBD>:\n");
for(j=0;j<10;j++)
{
printf("[%d]%.2f ",j+1,st[i].score[j]);
}
printf("\n");
break;
}
}
getchar();getchar();
return 0;
}
int grade_modify()
{
int id,i;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&id);
for(i=0;i<snum;i++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>course[]<5D><><EFBFBD>Ҷ<EFBFBD>Ӧ<EFBFBD><D3A6> <20>γ<EFBFBD>id
{
if(st[i].id==id)//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf(" <20><><EFBFBD><EFBFBD>:%04d <20><><EFBFBD><EFBFBD>:%s :ƽ<><C6BD><EFBFBD><EFBFBD>%.2f \n",st[i].id,st[i].name,st[i].sum);
int j;
printf("ʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>ɼ<EFBFBD>:\n");
for(j=0;j<10;j++)
{
printf("[%d]%.2f ",j+1,st[i].score[j]);
}
printf("\n");
while(1)
{
int k;
printf("\n\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵڼ<EFBFBD>λ<EFBFBD><EFBFBD>ί<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:") ;
scanf("%d",&k);
printf("\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>³ɼ<EFBFBD>:");
scanf("%lf",&st[i].score[k-1]);
printf("\t\tʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ί<EFBFBD>ɼ<EFBFBD>:\n");
for(j=0;j<10;j++)
{
printf("[%d]%.2f ",j+1,st[i].score[j]);
}
printf("\n");
printf("\t\t<EFBFBD>޸ijɹ<EFBFBD><EFBFBD><EFBFBD>\n");
printf("\t\t<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ĵ<EFBFBD><EFBFBD>˳ɼ<EFBFBD> (y/n) : ");
int flag;
scanf("%d",&flag);
if(flag==0)
break;
//printf("gg");
}
// printf("kk");
double mi=0xffffff,ma=0;
for( j=0;j<10;j++)
{
if(mi>st[snum].score[j])
{
mi=st[snum].score[j];
}
if(ma<st[snum].score[j])
{
ma=st[snum].score[j];
}
st[snum].sum+=st[snum].score[j];
}
st[snum].sum=st[snum].sum-mi-ma;
st[snum].sum/=8;
break;
}
}
save();
return 0;
}
int find_order()
{
int v[105]={0};
int i,number;
srand((unsigned) time(NULL)); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>ÿ<EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
for(i=0; i<snum; i++)
{
number = rand() % 100+1; //<2F><><EFBFBD><EFBFBD>0-100<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// printf("%d ", number);
if(v[i]==0)
{
v[number]=i+1;
}
else {
i--;
}
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>\n");
printf("__________________\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> | <20><><EFBFBD><EFBFBD> | <20><><EFBFBD><EFBFBD>\n\n");
int k=1;
for(i=0;i<101;i++)
{
if(v[i]!=0)
{
printf("[%02d] | %04d | %s \n",k,st[v[i]-1].id,st[v[i]-1].name);
k++;
}
}
getchar();getchar();
return 0;
}
result_sort() /**********************<2A><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>*********************************/
{
printf("ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");/****************<2A><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>************/
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>");
int k,i,j;
scanf("%d",&k);
if(k==1)
{
for(i=0;i<snum-1;i++) //ð<><C3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
for(j=0;j<snum-1-i;j++)
{
if(st[j].sum<st[j+1].sum) //sΪ<73><CEAA>ʱ<EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
s=st[j];
st[j]=st[j+1];
st[j+1]=s;
}
}
}
}
else{
for(i=1;i<snum;i++)
{
s = st[i]; //<2F><>Ҫ<EFBFBD>Ƚϵ<C8BD>ֵ<EFBFBD><D6B5><EFBFBD><E7B7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
j = i - 1;
while(j>=0 && st[j].sum<s.sum) //<2F>Ƚ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>s.sum<75><6D><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ҵ<EFBFBD>ͷ
{
st[j+1] = st[j]; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
j--;
}
st[j+1] = s; //<2F><><EFBFBD><EFBFBD>st[j]<5D>ĺ<EFBFBD><C4BA><EFBFBD>
}
}
for(i=0;i<snum;i++)
{
printf("\n---------------------------------------------|\n");
printf("| <20><><EFBFBD><EFBFBD>:%04d | <20><><EFBFBD><EFBFBD>:%s | ƽ<><C6BD><EFBFBD><EFBFBD>%.2f \n",st[i].id,st[i].name,st[i].sum);
}
getchar();
getchar();
}