在线求C语言问题答案,请高手帮帮我~~~~~~~~~~~

二、程序阅读题(共20分)
试题1(每小题2.5分,共10分)
阅读下列程序并回答问题。
【程序】
有一个班,3个学生,各学4门课,计算总平均分数,以及第n个学生的成绩。用函数averaGe求总平均成绩,用函数search找出并输出第i个学生的成绩。程序如下:
#include <stdio.h>
void main()
{
void average(float *p,int n);
void search(float (*p)[4],int n);
float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
average( (1) ,12); /*求12个分数的平均分*/
search(score,2); /*求第2个学生成绩�*/
}
void average(float *p,int n)
{
float *end;
float sum=0,aver;
end=p+n-1;
for(;p<=end;p++)
(2) ;
aver=sum/n;
printf("average=%5.2f\n", (3) );
}
void search(float (*p)[4],int n)
{
int i;
printf("the score of No.%D are:\n",n);
for(i=0;i<4;i++)
printf("%5.2f ", (4) );
}

试题2(每小题2.5分,共10分)
阅读下列程序并回答问题。
【程序】
#include <stdio.h>
void myswap(int, int);
void myswapp(int*, int*);

void main()
{
int a, b, *pa, *pb;

pa = &a;
a = 5;
b = 7;
pb = &b;
myswap(a, b);
printf("a = %d, b = %d\n", a, b);
myswapp(&a, &b);
printf("a = %d, b = %d\n", a, b);
}

void myswap(int x, int y)
{
int nTemp;

nTemp = x;
x = y;
y = nTemp;
}

void myswapp(int *x, int *y)
{
int nTemp;

nTemp = *x;
*x = *y;
*y = nTemp;
}

(1) 程序的输出是 (1) 、 (2) 。
(2) 将main函数中的语句“myswap(a, b);”改为“myswap(*pa, *pb);”,语句“myswapp(&a, &b); ” 改为“myswap(pa, pb);”后程序的输出结果是 (3) 、 (4) 。

三、编程题(共40分)
1. 编写程序,输入3个学生的姓名、学号以及成绩,通过结构体数组保存,并且将总成绩和平均成绩计算完,输出打印出来。

2. 现在要求编写一段去除多余空格程序,将用户输入的字符串中连续出现的多个空格替换成一个空格,并且显示出来;比如用户输入“today is b irthday !”,处理成为“today is birthday !”

第1个回答  2011-05-04
#include <stdio.h>
void main()
{
void average(float *p,int n);
void search(float (*p)[4],int n);
float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
average(*score,12); /*求12个分数的平均分*/
search(score,2); /*求第2个学生成绩�*/
}
void average(float *p,int n)
{
float *end;
float sum=0,aver;
end=p+n-1;
for(;p<=end;p++)
sum=sum+*p ;
aver=sum/n;
printf("average=%5.2f\n", aver);
}
void search(float (*p)[4],int n)
{
int i;
printf("the score of No.%D are:\n",n);
for(i=0;i<4;i++)
printf("%5.2f ",p[n][i]);
}

2=====
a=5 b=7
a=7 b=5

a=5 b=7
a=5 b=7

编程题没时间写了。本回答被网友采纳
第2个回答  2011-05-04
期末考题?二级?自己做一下比较好!
第3个回答  2011-05-04
最讨厌上来问试题的人

而且还一问问一大堆
相似回答