网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

试题24

有以下程序

#include <stdio.h>

double f(double x);

main()

{ double a=0; int i;

for(i=0;i<30;i+=10) a+=f((double)i);

printf(“%5.0f\n”, a);

}

double f(double x)

{ return x*x+1;}

程序运行后的输出结果是()

A.503

B.401

C.500

D.1404


参考答案

更多 “ 试题24有以下程序#include stdio.hdouble f(double x);main(){ double a=0; int i;for(i=0;i30;i+=10) a+=f((double)i);printf(“%5.0f\n”, a);}double f(double x){ return x*x+1;}程序运行后的输出结果是()A.503B.401C.500D.1404 ” 相关考题
考题 有以下程序int fun1(double a){return a*=a;}int fun2(double x,double y){ double a=0,b=0;a=fun1(x);b=fun1(y);return(int)(a+b);}main(){ double w; w=fun2(1.1,2.0); …… }程序执行后变量 w 中的值是A)5.21B)5C)5.0D)0.0

考题 以下程序的输出结果是______。 include int add(int x, int y) { return x+y; } doub 以下程序的输出结果是______。include<iostream.h>int add(int x, int y){return x+y;}double add(double x, double y){return x+y;}void main(){int a=3, b=3;double c=6.5, d=1.5;cout<<add(a, b)<<","<<add(c, d)<<end1;}

考题 有以下程序include using namespace std;class Complex{public: Complex(double r=O, 有以下程序 #include<iostream> using namespace std; class Complex { public: Complex(double r=O,double i=0):re(r),im(i){} double real() const {return re;} double imag()const {return im;} Complex operator +(Complex C) const {return Complex (re+c.re,im+c.im);} private: double re,im; }; int main() { Complex a=Complex(1,1)+Complex (5); cout<<a.real()<<'+'<<a.imag()<<'i'<<endl; retum 0; } 程序执行后的输出结果是A.6+6iB.6+1iC.1+6iD.1+1i

考题 请补充函数fun(),该函数的功能是求一维数组x[N]的平均值,并对所得结果进行四舍五入(保留两位小数)。例如:当x[10]={15.6, 19.9, 16.7, 15.2, 18.3, 12.1, 15.5,11.0, 10.0, 16.0},结果为:avg=15.030000。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仪在函数fun的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>double fun(double x[10]){int i;long t;double avg=0.0;double sum=0.0;for(i=0;i<l0;i++)【 】;avg=sum/10;avg=【 】;t=【 】;avg=(double)t/100;return avg;}main(){double avg,x[10]={15.6,19.9,16.7,15.2,18.3,12.1,15.5,11.0,10.0,16.0};int i;clrscr();printf(“\nThe original data is:\n”);for(i=0;i<l0;i++)printf("%6.lf",x[i]);printf(“\n\n”);avg=fun(x);printf(“average=%f\n\n”,avg);}

考题 请补充函数fun(),该函数的功能是:计算N×N维矩阵元素的方差,结果由函数返回。维数N在主函数中输入。例如:注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>include <conio.h>include <stdlib.h>include <math.h>define N 20double fun(【 】,int n){int i,j;int k;double s=0.0;double f=0.0;double aver=0.0;double sd=0.0;for(i=0;i<n;i++)for(j=0;j<n;j++)s+=a[i][j];aver=【 】;for(i=0;i<n;i++)for(j=0;i<n;j++)f+=(a[i][j]-aver)*(a[i][j]-aver);f/(n*n);sd=【 】;return sd;}main(){int a[N][N];int n;int i,j;double s;clrscr();printf("***+Input the dimension ofarray N*****\n");scanf("%d",n);printf("***** The array *****\n");for(i=0;i<n;i++){for(j=0;j<n;j++){a[i][j]=rand()%50;while(a[i][j]=0)a[i][j]=rand()%60;printf("%4d",a[i][j]);}printf("\n\n");}s=fun(a,n);printf("******* THE RESULT *******\n");printf("%4.3f\n",s);}

考题 请补充函数fun,其功能是:计算并输出给定10个数的方差:例如,给定的10个数为15.0,19.0,16.0,15.0,18.0,12.0, 15.0,11.0,10.0,16.0,输出为s=2.758623。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<math. h>double fun (double x[10]){int i;double avg=0.0;double sum=0.0;double abs=0.0;double sd;for (i=0; i<10; i++)【 】;avg=sum/10;for(i=0;i<10;i++)【 】;sd=【 】;return sd;}main(){double s,x[10]={15.0,19.0,16.0,15.0,18.0,12.0,15.0,11.0,10.0,16.0};int i;printf("\nThe original data is :\n");for(i=0;i<10;i++)printf("%6.1f",x[i]);printf("\n\n");s=fun(x);printf("s=%f\n\n",s);}

考题 有以下程序include using namespacestd;class Complex{public:Complex (doubler=0, d 有以下程序 #include <iostream> using namespace std; class Complex { public: Complex (double r=0, double i =0 :re(r) ,im (i) {} double real() const {return re;} double imag() const { return im;} Complex operator + (Complex c} const {return Complex(re+c.re, im+c.im);} privane: double re,im; }; int main { Complex a =Complex (1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag() << 'i' <<endl return 0; } 程序执行后的输出结果是A.6+6iB.6+1iC.1+6iD.1+1i

考题 有以下程序include using namespace std;class Complex{public:Complex(double r=0,d 有以下程序#include <iostream>using namespace std;class Complex{public: Complex(double r=0,double i=0):re(r),im(i){ double real() const {return re;} double imag() const { return im; } Complex operator+(Complex c) const {return Complex(re+c.re,im+c.im);}private: double re,im;};int main(){ Complex a =Complex(1,1)+ Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end1; retura 0;}A.6+6iB.6+1iC.1+6iD.1+1i

考题 下列给定程序中,函数fun()的功能是:根据整型参数m,计算如下公式的值。y=1/(100×100)+1/(200×200)+1/(300×300)+…+1/(m×m)例如,若m=2000,则应输出0.000160。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio. h>/*************found**************/fun (int m){ double y=0, d;int i;/*************found**************/for (i=100, i<=m, i+=100){d= (double) i* (double) i;y+=l. 0/d;}return (y);}main ( ){ int n=2000;clrscr();printf("\nThe result is %lf\n",fun(n));

考题 分析以下程序执行结果【】。 include int f (int x, int y){return x,y; } double f (d 分析以下程序执行结果【 】。include<iostream.h>int f (int x, int y){return x,y;}double f (double x, double y) {return x,y;}void main() {int a=4, b=6;double c=2.6, d=7.4;cout<<f (a, b) <<","<<f (c, d) <<end1;}

考题 有下列程序: int funl(double a){return a*=a;} int fun2(double x,double y) {double a=0,b=0; a=funl(x);b=funl(y);return(int)(a+b); } main( ) {double w;w=fun2(1.1,2.0),……} 程序执行后变量w中的值是( )。 、A.5.21B.5C.5.0D.0.0

考题 有以下程序,输出结果()。includeusing namespace std;class Complex{public:Complex(d 有以下程序,输出结果( )。 #include<iostream> using namespace std; class Complex { public: Complex(double r=0,double i=0):re(r),im(i){} double real()const{return re;} double imagoconst{return im;} Complex operator+(Complex C) const {return Complex(re+c.re,im+c.im);} private: double re,im; }; int main() { Complex a=Complex(1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end1; return 0; }A.6+iB.2i+5C.6+1iD.1i+5

考题 下列程序的执行结果为【 】。include class Point{public:Point(double i, double j) 下列程序的执行结果为【 】。include <iostream. h>class Point{public:Point(double i, double j) { x=i; y=j;}double Area() const { return 0.0;}private:double x, y;};class Rectangle: public Point{public:Rectangle(double i, double j, double k, double 1)double Area() const {return w * h;}private:double w, h;};Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).{w=k, h=1}void fun(Point s){cout<<s. Area()<<end1;}void main( ){Rectangle rec(3.0, 5.2, 15.0. 25.0);fun(rec)}

考题 有以下程序:int fun1 (double a){ return a * =a;}int fun2 ( double x, double y ){ double a=0,b=0; a = fun1 (x) ;b = fun1 (y); return(int) (a + b);} main() { doublew;w=fun2(1.1,2.0);……} 程序执行后变量w中的值是( )。A.5.21B.5C.5D.0

考题 以下函数的功能是:求x的y次方,请填空。double fun(double x,int y){ int i; double z; for(i=1,z=x;iy;i++) z=z*; return z;}

考题 写出下列程序的运行结果【】。 include void func(double x, int part1, double 写出下列程序的运行结果【 】。include<iostream. h>void func(double x, int part1, double part2){part1=int(x)+500:part2=(x+500-part1)*100;}void main( ){int n;double x, f;x=1001. 0103;func (x, n, f):cout<<"Part 1="<<n<<" , part2="<<f<<end1}

考题 有以下程序: include using namespace std; class Complex{public: Complex(double 有以下程序: #include <iostream> using namespace std; class Complex { public: Complex(double r=0,double i=0):re(r),im(i){ double zeal() const {return re;} double imag() const {return im;} Complex operator+(Complex c) const { return Complex(re+c.re,im+c.im);} private: double re,im; }; int main() Complex a=Complex(1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end 1; return 0; }程序执行后的输出结果是______。A.6+6iB.6+1iC.1+6iD.1+1i

考题 以下程序的输出结果是【】。 include int add(int x,int y) { retum X+y; } dOuble ad 以下程序的输出结果是【 】。include<iostream.h>int add(int x,int y){retum X+y;}dOuble add(dOUble x,double y){return x+y;}void main(){int a=4,b=6;double c=2.6,d=7.4;cout<<add(a,b)<<",”<<add(C,d)<<endl;}

考题 下列给定程序中,函数fun()的功能是:计算S=f(-n)+f(-n+1)+…+f(0)+f(1)+f(2)+…f(n)的值。例如,当n为5时,函数值应为10.407143。f(x)函数定义如下:请改正程序中的错误,使它能得山正确的结果。注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio. h>include <stdio. h>include <math. h>/**************found***************/f (double x){if (x==0.0 || x==2.0)return 0.0;else if (x<0.0)return (x-1) / (x-2);elsereturn (x+1) / (x-2);}double fun(int n){int i; double s=0.0,y;for (i=-n; i<=n; i++){ y=f(1.0*i); s+=y;}/**************found**************/return s}main(){ clrscr();printf ("%f\n", fun (5));}

考题 有以下程序: #includestdio.h double f(double x); main( ) {double a=0; int i; for(i=0;i30;i+=10)a+=f((double)i); printf("%5.of\n",a); } double f(double x) { return x*x+1; } 程序运行后的输出结果是( )。A.503B.401C.500D.1404

考题 有以下程序:include include using namespace std;class point{private: doub 有以下程序: #include <iostream> #include <math> using namespace std; class point { private: double x; double y; public: point(double a,double b) { x=a; y=b; } friend double distance(point a,point b) ; }; double distance(point a,point b) { return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } int main ( ) { point pl(1,2); point p2 (5, 2); cout<<distance (pl,p2) <<end1; return 0; } 程序运行后的输出结果是( )。A.1B.5C.4D.6

考题 有以下程序 int fun1 (double a){return a*=a;} int fun2 (double x,double y) { double a=0,b=0; a=fun1(x);b=fun1(y); return(int)(a+b); } main() {double w;w=fun2(1.1,2.0);......} 程序执行后变量W中的值是______。A.5.21B.5C.5D.0

考题 有以下程序; int f1(double A) { return a*a; } int f2(double x,double y) { double a, b; a=n(x); b=f1(y); return a+b; } main() { double w; w=f2(1.1,2.0); ┇ } 变量w中的值是( )A.5.21B.5C.5D.0

考题 有以下程序#includestdio.hdouble f(double x);main(){ double a=0;int i;for(i=0;i30;i+=10) a+=f((double)i);printf("%5.0f\n",a);}double f(double x){return x*x*i;}程序运行后的输出结果是A.503B.401C.500D.1404

考题 如果已经定义了方法int f(bool b, int i),则以下方法中,哪一个不是合法的重载方法()。A、double f(bool b, int i)B、int f(double d, int i)C、int f(bool b,int i, double d)D、double f(bool d, int j)

考题 单选题有以下程序#includeint fun1(double a){ return (int)(a*= a);}int fun2(double x,double y){ double a = 0,b = 0; a = fun1(x); b = fun1(y); return (int)(a+b);}main(){ double w; w = fun2(1.1,2.0); printf(%4.2f,w);}程序执行后输出结果是(  )。A 5B 5.00C 5.21D 0.0

考题 单选题有以下程序:#includefloat fun(double a){ double x; x=a-(int)a; return x;}main(){ double a=3.1415; printf(%f,fun(a));}程序的运行结果是(  )。A 3.000000B 3.141500C 0.141500D 0.000000