各位大虾帮忙找下错误啊,帮我改正改正,急!!
用链表实现一个有n个裁判打分系统,打分规则,在n个裁判打分以后计算时去掉一个最高分和最底分的平均分,某个或者某些裁判不打分或者打出不合理的分数,要求提示错误并重新开始打分。以下是程序,编译无错,但是结果全部是0,能不能帮我解决下啊,万分感谢啊!!***********************************
#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("\nhow many pingwei do you want.please enter a number\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("di%dwei pingwei ",i+1);
scanf("%f",&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=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("\nthe max score is %f,the min score is %f,\n now delete them",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("\nqu diao zui gao fen he zui di fen,the final score is: %f",s/n-2);
}
*************************************
希望各位大虾能帮忙啊