#include<stdio.h>
#include<stdlib.h>
struct a{
struct a *next;
double data;
}
main()
{
struct a *h,*p,*m,*q;
int i,n,s=0;
double x;
/*声明头指针*/
h=(struct a*)malloc(sizeof(struct a));
if(h==NULL)
printf("error");
/*产生链表*/
printf("how many pingwei do you want.please enter a number\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("the %d pingwei ",i+1);
scanf("%lf",&x);
p=h;
while(p!=NULL) p=p->next;
m=(struct a *)malloc(sizeof(struct a));
m->data=x;
m->next=NULL;
p=m;
}
/*p指向最大的分数,q指向最小的分数*/
p=h->next;
q=p->next;
m=q->next;
i=p->data>q->data?1:0; /* 不清楚那个大 所以用这个*/
if(i==0)
{
q=p;p=p->next;
}
while(m!=NULL)
{
if(p->data>m->data&&q->data>m->data)
q=m;
else
p=m;
m=m->next;
}
/*删除那俩个节点*/
printf("the max score is %lf,the min score is %lf,\n now delete they",p->data,q->data);
/*删除大的结点*/
/*有没什么好的方法 把这俩个结合起来?*/
m=h;
while(m->next!=p)
{
m=m->next;
}
if(p->next==NULL)
m->next=NULL;
else
m->next=p->next;
/*删除小的结点*/
m=h;
while(m->next!=q)
{
m=m->next;
}
if(q->next=NULL)
m->next=NULL;
else
m->next=q->next;
p=h->next;
/*求和和平均*/
while(p!=NULL)
{
s+=p->data;
p=p->next;
}
printf("qu diao zui gao fen he zui di fen %lf",s/n-2);
}