更多"下面程序通过函数average( )计算数组中各元素的平均值。
"的相关试题:
[填空题]下面的程序通过函数average计算数组中各元素的平均值,请填空。
float avetage(int * pa,int n)
int i;
float avg=0.0;
for(i=0;i<n;i+ +);
avg=avg+______;avg=______;
return avg;
main( )
int i,a[5]=2,4,6,8,10,;
float mean;
prinf("% mean=% f/n",mean);
[填空题]下面是一个JavaApplet程序,请将程序补充完整使它的功能为计算数组各元素的平均值。
import java.applet.Applet;
import java.awt.*;
public class Exam extends Applet
public void paint(Graphics g)
int a[ ]=1,3,5,7,9,10;
int total=0;
float ave;
for(int i=0; i<A.length;i++)
total+=a[i];
ave=total/
g.drawstring("ave="+ave,30,60);
[填空题]下面是一个Java Applet程序,请将程序补充完整使它的功能为计算数组各元素的平均值。
import java.applet.Applet;
import java.awt.*;
public class Exam extends Applet{
public void paint(Graphics g){
int a[]={1,3,5,7,9,10};
int total=0;
float ave;
for(int i=0;i<A.length;i++)
total+=a[i];
ave=total 【13】 ;
g.drawstring("ave="+ave,30,60);
}
}
[填空题]下面是一个Java Applet程序,请将程序补充完整使它的功能为计算数组各元素的平均值。
import java.applet.Applet;
import java.awt.*;
public class Exam extends Applet
public void paint(Graphics g)
int a[]=1,3,5,7,9,10;
int total=0;
float ave;
for(int i=0;i<A.length;i++)
total+=a[i];
ave=total 【13】 ;
g.drawstring("ave="+ave,30,60);
[填空题]下列给定程序中,函数fun( )的功能是:给定n个实数,输出平均值,并统计平均值以上(含平均值)的实数个数。例如, n=8时,输入193.199,195.673,195.757,196.051,196.092, 196.596,196.579,196.763,所得平均值为195.838745,在平均值以上的实数个数应为5。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
int fun(float x[], int n)
/***************found*******************/
iht j, c=0;float xa=0.0;
for (j=0; j<n;.j++)
xa+=x[j]/n;
printf("ave=%f/n",xa);
for (j=0; j<n;j++)
if(x[j]>=xa)
c++;
returnc;
}
main( )
{float x[l00]={ 193.199,195.673,195.757,
196.051,196.092,196.596,
196.579,196.763};
clrscr ( );
printf("%d/n",fun (x,8));
}
[填空题]下列是一个Java Applet程序,填空使它的功能为计算数组各元素和的平均值。
import java applet. * ;
import java awt. * ;
public class Testvv extends Applet
{
pubfic void paint(Graphics g)
{
int a[ ]= { 1,3,5,7,9,10 };
double total=0.0,ave=0.0;
for(int i=0;i<a.length;i++)
total+=a[i];
ave=total/ 【 】;
g.drawstring("ave="+ave,30,60);
}
}
[填空题]下列是一个Java Applet程序,填空使它的功能为计算数组各元素和的平均值。
import java applet.*;
import java awt.*;
public class Testvv extends Applet
{
public void paint(Graphics g)
{
int a[ ]={1,3,5,7,9,10};
double total=0.0, ave=0.0;
for(int i=0;i<a.length;i++)
total+=a[i];
ave=total/ 【9】 ;
g. drawstring ( "ave="+ave, 30, 60; )
}
}
[填空题]下列是一个Java Applet程序,填空使它的功能为计算数组各元素和的平均值。
import java applet.*;
import java awt.*;.
public class Testvv extends Applet
public void paint(Graphics g)
int a []=1,3,5,7,9,10 ;
double total=0.0,ave=0.0;
for(int i=0;i<a.length;i++)
total+=a[i];
ave=total/______;
g.drawString("ave="+ave,30,60);
[填空题]请补充main函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。
程序运行后的结果为42.40。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
{
int i, j, n=0,flag;
float aver=0;
clrscr( );
for(j=2;j<100;i++)
{
flag=1;
for(i=2;i<j;i++)
if( 【1】 )
{
flag=0;
break;
}
if( 【2】 )
{
n++;
aver+=j;
}
}
printf("/n/n average=%4.2f", 【3】 );
}
[填空题]请补充main函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。
程序运行后的结果为42.40。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
int i, j, n=0,flag;
float aver=0;
clrscr( );
for(j=2;j<100;i++)
flag=1;
for(i=2;i<j;i++)
if( 【1】 )
flag=0;
break;
if( 【2】 )
n++;
aver+=j;
printf("/n/n average=%4.2f", 【3】 );