下列给定程序中,函数fun()的功能是:从n个学生的成绩中统计出高于平均分的学生人数,人数由函数值返回,平均分存放在形参aver所指的存储单元中。例如输入8名学生的成绩:
85 65.5 69 95.5 87 55 62.5 75
则高于平均分的学生人数为4(平均分为74.312500)。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conio.h>
define N 20
int fun(float *S,int n,float *aver)
{
/*************found*************/
int ave,t=0;
int count=0,k,i;
for(k=0;k<n;k++)
t+=s[k];
ave=t/n;
for(i=0;i<n;i++)
/*************found***************/
if(s[i]<ave)
count++;
/*************found*************/
aver=ave;
return count;
}
main()
{
float S[30],aver;
int m,i;
clrscr();
printf("\nPlease enter m:");
scanf("%d",&m);
printf("\nPlease enter%d mark:\n",m);
for(i=0;i<m;i++)
scanf("%f",s+i);
printf("\nThe number of students:%d\n",
fun(S,m,&aver));
printf(“AVe=%f\n”,aver);
}
第1题
85 65.5 69 95.5 87 55 62.5 75
则高于平均分的学生人数为4(平均分为74.312500)。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conio.h>
define N 20
int fun(float *S,int n,float *aver)
{
/*************found*************/
int ave,t=0;
int count=0,k,i;
for(k=0;k<n;k++)
t+=s[k];
ave=t/n;
for(i=0;i<n;i++)
/*************found***************/
if(s[i]<ave)
count++;
/*************found*************/
aver=ave;
return count;
}
main()
{
float S[30],aver;
int m,i;
clrscr();
printf("\nPlease enter m:");
scanf("%d",&m);
printf("\nPlease enter%d mark:\n",m);
for(i=0;i<m;i++)
scanf("%f",s+i);
printf("\nThe number of students:%d\n",
fun(S,m,&aver));
printf(“AVe=%f\n”,aver);
}
第2题
80.5 60 72 90.5 98 51.5 88 64
则低于平均分的学生人数为4(平均分为75.5625)。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <conio.h>
define N 20
int fun(float *s, iht n,float *aver)
{ float ave ,t=0.0;
int count=0,k,i;
for(k=0;k<n;k++)
/*************found**************/
t=s[k];
ave=t/n;
for(i=0;i<n;i++)
if(s[i]<ave) count++;
/*************found**************/
*aver=&ave;
return count;
}
main()
{ float s[30],aver;
int m,i;
clrscr();
printf("\nPlease enter m: "); scanf
("%d",&m);
printf("\nPlease enter %d mark :\n",m);
for(i=0;i printf("\nThe number of students :
%d\n",fun(s,m,&aver));
printf("Ave=%f\n",aver);
}
第3题
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
include <conio.h>
include <string.h>
include <stdio.h>
include <alloc.h>
define N 10
typedef struct ss
{char num[10];
int s;
} STU;
STU *fun{STU a[], int m)
{ STU b[N] ,*t;
int i, j,k;
/*************found**************/
*t=calloc (m, slzeof (STU));
for(i=0;i<N;i++) b[i]=a[i];
for(k=0; k<m; k++)
{ for (i=j=0;i<N;i++)
if (b[i].s>b[j].s) j=i;
/*************found**************/
t[k].num=b [j].num;
t[k].s=b[j] s;
b[j].s=0;
}
return t;
}
outresult(STU a[],FILE *pf)
{ int i;
for (i=0; i<N; i++)
fprintf(pf, "No=%s Mark-%d\n ",
a [i] .num, a[i].s);
fprintf(pf, "\n\n ");
}
main ( )
{ STU a[N]={{ "A01 ",81},{ "A02 ",89},
{ "A03 ",66},{ "A04 ",87},{ "A05 ",77},
{ "A06 ",90},{ "A07 ",79},{ "A08 ",61},
{ "A09 ",80},{ "Al0 ",71}};
STU *pOrder;
int i, m;
clrscr ();
printf ("*****THE RESULT***** \n");
outresult (a, stdout);
printf ("\nGive the number of the students
who have better score: ");
scanf ("%d", &m);
while (m>10)
{ printf("lnGive the number of the
students who have better score: ");
scanf ("%d", %m);
pOrder=fun (a,m);
printf("***** THE RESULT*****kn");
printf("The top :\n");
for (i=0; i<m; i++)
printf("%s %d\n",pOrder[i].num,
p0rder [i]. s);
free (pOrder);
}
第4题
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio.h>
include <string.h>
include <stdio.h>
include <alloc.h>
define N 10
typedef struct SS
{
char num[10];
int s;
}STU;
STU *fun(STU a[],int m)
{
STU b[N],*t;
int i, j,k;
/*************found*************/
*t=calloc(m,sizeof(STU));
for(i=0;i<N;i++)
b[i]=a[i];
for(k=0;k<m;k++)
{
/*************found*************/
for(i=j=0;i<N;j++)
if(b[i].s<b[j],s)
j=i;
/*************found*************/
t[k].s=b[j].s;
b[j].s=100;
}
return t;
}
outresult(STU a[],FILE *pf)
{
int i;
for(i=0;i<N;i++)
fprintf(pf,"NO=%S Mark=%d\n",
a[i].num,a[i].S);
fprintf(pf,"\n\n");
}
main()
{
STU a[N]={{“A01”,77},{“A02”,85},
{“A03”,96},{“A04”,65},{“A05”,75},
{“A06”,96},{“A07”,76},{“A08”,63},
{“A09”,69},{“A10”,78}};
STU *porder;
int i,m;
clrscr();
printf(“*****THE RESULT*****\n”);
outresult(a,stdout);
printf(“\nGive the number of the students who have lower score:”);
scanf(“%d”,&m);
while(m>10)
{
printf(“\nGive the number of the students who have lower score:”);
scanf(“%d”,&m);
}
porder=fun(a,m);
printf(“*****THE RESULT*****\n”);
printf(“The low:\n”);
for(i=0;i<m;i++)
printf(“%s %d\n”,porder[i].num,
porder[i].s);
free(porder);
}
第5题
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
第6题
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:
第7题
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
第8题
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数flm的花括号中填入你编写的若干语句。
第9题
注意:部分源程序存在文件PROGl.C文件中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的莅括号中填入你编写的若干语句。
第10题
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!