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.

379 lines
9.3 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#define n 2 //<2F><><EFBFBD><EFBFBD>ѧУ<D1A7><D0A3>
#define m 1 //<2F><><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>
#define w 1 //Ů<>Ӿ<EFBFBD><D3BE><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>
typedef struct sco
{
int mark[5];//<2F><><EFBFBD><EFBFBD>
int itmnum;//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
int itmkind;//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
char itmname[20];//<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
char name[10];//<2F>˶<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
int l; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int range[5];//<2F><><EFBFBD><EFBFBD>
}sc;
typedef struct school
{
int sclnum;//ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
char sclname[20];//ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
sc a[m+w];
int mscore;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>
int wscore;//Ů<><C5AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>
int sum;//ѧУ<D1A7><D0A3>Ŀ<EFBFBD>ܷ<EFBFBD>
struct school *next;
}scl;
scl *p,*q,*head,*g,*s,*u;//ȫ<><C8AB>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/****************************************************************************/
/******************************<2A><> <20><> <20><> <20><>*********************************/
void menu()
{
system("cls");
printf("*********************** <20>˶<EFBFBD><CBB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>ϵͳ *********************\n");
printf("********************* *** <20><><EFBFBD><EFBFBD> ********************\n");
printf("** 1------------------->><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** 2------------------->><3E>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> **\n");
printf("** 3--------------------->><3E><><EFBFBD><EFBFBD> **\n");
printf("** 4--------------------->><3E><>ѯ **\n");
printf("** 5--------------------->><3E>˳<EFBFBD> **\n");
printf("**<2A><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ε÷֣<C3B7>7<EFBFBD><37> 5<><35> 3<><33> 2<><32> 1<><31> **\n");
printf("**Ů<><C5AE>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ε÷֣<C3B7>5<EFBFBD><35> 3<><33> 2<><32> **\n");
printf("=======================================================\n");
}
/******************************************************************************/
/*******************************<2A><> <20><> <20><> <20><>*******************************/
void compute(int i,int x,int k)
{
if(k==3) //Ů<><C5AE><EFBFBD><EFBFBD>Ŀȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>
{
switch(p->a[x].range[i])
{
case 0: p->a[x].mark[p->a[x].range[i]]=0;break;
case 1: p->a[x].mark[p->a[x].range[i]]=5;break;
case 2: p->a[x].mark[p->a[x].range[i]]=3;break;
case 3: p->a[x].mark[p->a[x].range[i]]=2;break;
default: puts("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");exit(0);
}
}
else
{
switch(p->a[x].range[i]) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>
{
case 0: p->a[x].mark[p->a[x].range[i]]=0;break;
case 1: p->a[x].mark[p->a[x].range[i]]=7;break;
case 2: p->a[x].mark[p->a[x].range[i]]=5;break;
case 3: p->a[x].mark[p->a[x].range[i]]=3;break;
case 4: p->a[x].mark[p->a[x].range[i]]=2;break;
case 5: p->a[x].mark[p->a[x].range[i]]=1;break;
default: puts("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");break;
}
}
}
/***********************<2A><> <20><> <20><> <20><>***********************/
scl *input() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBAAF>
{
int i,x,y=1,k;
p=(scl*)malloc(sizeof(scl)); //ͷ<><CDB7><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
printf("\n**<2A><><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EBA3A8>ͬѧУ<D1A7><D0A3><EFBFBD>Ų<EFBFBD><C5B2>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>룩**\n");
printf("**<2A><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>111---<2D><><EFBFBD><EFBFBD> 222---Ů<><C5AE> **\n");
printf("**ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>>>\n**ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>>>\n**<2A><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>>><3E><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>>><3E><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>><3E><><EFBFBD><EFBFBD>>><3E><><EFBFBD><EFBFBD>>>\n");
p->mscore=0;p->wscore=0;
scanf("%d",&p->sclnum);//<2F><><EFBFBD><EFBFBD>ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
scanf("%s",p->sclname);//<2F><><EFBFBD><EFBFBD>ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
for(x=0;x<m+w;x++)
{
scanf("%d",&p->a[x].itmnum);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
scanf("%d",&p->a[x].itmkind);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
scanf("%s",p->a[x].itmname);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
scanf("%d",&p->a[x].l);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<p->a[x].l;i++)
{
scanf("%d",&p->a[x].range[i]);//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
scanf("%s",p->a[x].name); //<2F>˶<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
}
if(p->a[x].itmkind==222) //<2F>Ʒַ<C6B7>ʽ<EFBFBD>ж<EFBFBD>
k=3;
else
k=5;
for(i=0;i<p->a[x].l;i++)
{
compute(i,x,k);
if(p->a[x].itmkind==222 ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF> 111<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF> 222<32><32>Ů<EFBFBD><C5AE><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>
p->wscore+=p->a[x].mark[p->a[x].range[i]];
else
p->mscore+=p->a[x].mark[p->a[x].range[i]];
}
}
p->sum=p->mscore+p->wscore; //<2F><>ѧУ<D1A7>ܳɼ<DCB3>
head=p;
q=p;
/********************************************************************/
while(y<n) //<2F><><EFBFBD><EFBFBD><EFBFBD>½ڵ<C2BD>
{
y++; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧУ<D1A7>ĸ<EFBFBD><C4B8><EFBFBD>
p=(scl*)malloc(sizeof(scl));
p->mscore=0;p->wscore=0;
scanf("%d",&p->sclnum);
scanf("%s",p->sclname);
for(x=0;x<m+w;x++)
{
scanf("%d",&p->a[x].itmnum);
scanf("%d",&p->a[x].itmkind);
scanf("%s",p->a[x].itmname);
scanf("%d",&p->a[x].l);
for(i=0;i<p->a[x].l;i++)
{
scanf("%d",&p->a[x].range[i]);
scanf("%s",p->a[x].name);
}
if(p->a[x].itmkind==222)
k=3;
else
k=5;
for(i=0;i<p->a[x].l;i++)
{
compute(i,x,k);
if(p->a[x].itmkind==222)
p->wscore+=p->a[x].mark[p->a[x].range[i]];
else
p->mscore+=p->a[x].mark[p->a[x].range[i]];
}
}
p->sum=p->mscore+p->wscore;
q->next=p;
q=p;
}
p->next=NULL;
menu();
return head;
}
/********************<2A><> <20><> <20><> <20><>********************/
void output(scl *head) //<2F><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
{
scl *q=head;
int i,x,y=1;
FILE *fp;
int co;
printf("****1---------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
printf("****2---------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
scanf("%d",&co);
switch(co)
{
case 1:
{
fp=fopen("d:\\abc.txt","w+");
if(fp==NULL)
{printf("<EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");exit(0);}
while(q!=NULL)
{
fprintf(fp,"%d\n",q->sclnum);
for(x=0;x<m+w;x++)
{
fprintf(fp,"%d\t\n",q->a[x].itmkind);
fprintf(fp,"%d\t\n",q->a[x].l);
for(i=0;i<q->a[x].l;i++)
fprintf(fp,"%d\t",q->a[x].range[i]);
fprintf(fp,"\n");
}
q=q->next;
}
fclose(fp);
}break;
case 2:
while(q!=NULL)
{
printf("===================================\n");
printf(" ѧУ<D1A7><D0A3><EFBFBD>ţ<EFBFBD>\t");
printf("%d\n",q->sclnum);
printf(" ѧУ<D1A7><D0A3><EFBFBD>ƣ<EFBFBD>\t");
printf("%s\n",q->sclname);
for(x=0;x<m+w;x++)
{
printf(" <20><>Ŀ<EFBFBD><C4BF><EFBFBD>ţ<EFBFBD>\t");
printf("%d\n",q->a[x].itmnum);
printf(" <20><>Ŀ<EFBFBD><C4BF><EFBFBD>ͣ<EFBFBD>\t");
printf("%d\n",q->a[x].itmkind);
printf(" <20><>Ŀ<EFBFBD><C4BF><EFBFBD>ƣ<EFBFBD>\t");
printf("%s\n",q->a[x].itmname);
printf(" <20><>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Σ<EFBFBD>\t",q->a[x].l);
for(i=0;i<q->a[x].l;i++)
{
printf("<EFBFBD><EFBFBD>%d<><64>\t",q->a[x].range[i]);
}
printf("\n\n");
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ܷ֣<EFBFBD>\t%d\n",q->mscore);
printf("Ů<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ܷ֣<EFBFBD>\t%d\n",q->wscore);
printf("ѧУ<EFBFBD><EFBFBD>Ŀ<EFBFBD>ܵ÷֣<EFBFBD>\t%d\n\n",q->sum);
printf("\n");
q=q->next;
}
break;
default :
puts("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
exit(0);
}
}
/********************<2A><> <20><> <20><> <20><> <20><> <20><>********************/
scl *read()
{
FILE *fpa=NULL;
int i,x,y=1,k;
p=(scl *)malloc(sizeof(scl));
p->mscore=0;p->wscore=0;
fpa=fopen("d:\\abc.txt","r+");//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
if(fpa==NULL)
{puts("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");exit(0);}
fscanf(fpa,"%d",&p->sclnum);
for(x=0;x<m+w;x++)
{
printf("<EFBFBD>Ѷ<EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>Ŀ\n",x+1);
fscanf(fpa,"%d%d%d",&p->a[x].itmnum,&p->a[x].itmkind,&p->a[x].l);
for(i=0;i<p->a[x].l;i++)
fscanf(fpa,"%d",&p->a[x].range[i]);
if(p->a[x].itmkind==222)
k=3;
else
k=5;
for(i=0;i<p->a[x].l;i++)
{
compute(i,x,k);
if(p->a[x].itmkind==222)
p->wscore+=p->a[x].mark[p->a[x].range[i]];
else
p->mscore+=p->a[x].mark[p->a[x].range[i]];
}
}
p->sum=p->mscore+p->wscore;
head=p;
q=p;
while(y<n)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧУ<D1A7><D0A3><EFBFBD><EFBFBD>
{
y++;
p=(scl *)malloc(sizeof(scl));
p->mscore=0;
p->wscore=0;
fscanf(fpa,"%d",&p->sclnum);
for(x=0;x<(m+w);x++)
{
printf("<EFBFBD>Ѷ<EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>Ŀ\n",x+1);
fscanf(fpa,"%d%d",&p->a[x].itmnum,&p->a[x].itmkind);
fscanf(fpa,"%d",&p->a[x].l);
for(i=0;i<p->a[x].l;i++)
fscanf(fpa,"%d",&p->a[x].range[i]);
if(p->a[x].itmkind==222)
k=3;
else
k=5;
for(i=0;i<p->a[x].l;i++)
{
compute(i,x,k);
if(p->a[x].itmkind==222)
p->wscore+=p->a[x].mark[p->a[x].range[i]];
else
p->mscore+=p->a[x].mark[p->a[x].range[i]];
}
}
p->sum=p->wscore+p->mscore;
q->next=p;
q=p;
}
p->next=NULL;
fclose(fpa);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
return head;
}
/**************<2A><> <20><> <20><> <20><>***************/
void find(scl *head)
{
scl *q=head;
int num,x,i,cha,xiang,flag=0;
printf("<EFBFBD><EFBFBD>ѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2\n");
scanf("%d",&cha);
if(cha==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѧУ<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
while(q!=NULL)
{
if(num==q->sclnum)
{
printf("===================================\n");
printf("ѧУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("%d\n",q->sclnum);
for(x=0;x<m+w;x++)
{
printf("<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("%d\t\n",q->a[x].itmnum);
printf("<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("%d\t\n",q->a[x].itmkind);
printf("<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\t",q->a[x].l);
for(i=0;i<q->a[x].l;i++)
{
printf("<EFBFBD><EFBFBD>%d<><64>\t",q->a[x].range[i]);
}
printf("\n\n");
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ܷ֣<EFBFBD>%d\n",q->mscore);
printf("Ů<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ܷ֣<EFBFBD>%d\n",q->wscore);
printf("ѧУ<EFBFBD><EFBFBD>Ŀ<EFBFBD>ܵ÷֣<EFBFBD>%d\n\n",q->sum);
printf("\n");
flag=1;
printf("\n");
}
q=q->next;
}
if(flag==0)
puts("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>");
}
else if(cha==2)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&xiang);
while(q!=NULL)
{
for(x=0;x<m+w;x++)
{
if(xiang==q->a[x].itmnum&&q->a[x].itmkind==111)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧУΪ:\n");
for(i=0;i<5;i++)
printf("ѧУ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒֱ<EFBFBD>Ϊ:%d,%s\n",q->sclnum,q->sclname);
flag=1;
break;
}
else
if(xiang==q->a[x].itmnum&&q->a[x].itmkind==222)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧУΪ:\n");
for(i=0;i<3;i++)
printf("ѧУ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒֱ<EFBFBD>Ϊ:%d,%s\n",q->sclnum,q->sclname);
flag=1;
break;
}
}
q=q->next;
}
if(flag==0)
puts("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>");
}
}
/**********************<2A><> <20><> <20><>*************************/
void main() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
{
int ch;
menu();
while(1)
{
printf(">>>>>>>>><3E><>ѡ<EFBFBD><D1A1>\t");
scanf("%d",&ch);
switch(ch)
{
case 1: menu();g=input(); break;
case 2: menu();g=read(); break;
case 3: menu();output(g); break;
case 4: menu();find(g); break;
case 5: menu();puts("*********************лл<D0BB><D0BB><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD>");exit(0);
default: menu();puts("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");exit(0);
}
}
}