有下列函数定义: fun(float h) { printf("%f,%f\n",h,h*h);) 该函数的类型是( )。
A.int类型
B.float类型
C.void类型
D.函数无类型说明,定义有错
第1题:
有下列函数定义: fun(float h) { printf("%f,%f\n",h,h*h);} 该函数的类型是( )。
A.int类型
B.float类型
C.void类型
D.函数无类型说明,定义有错
第2题:
有下列函数定义:
fun(float h)
{ printf("%f,%f\n”,h,h*h);}
该函数的类型是( )。
A.int类型
B.float类型
C.void类型
D.函数无类型说明,定义有错
第3题:
请编一个函数float fun (double h),函数的功能是对变量h中的值保留两位小数,并对第三位进行四舍五入(规定h中的值为正数)。
例如:若h值为8.32433,则函数返回8.32:若h值为 8.32533,则函数返回8.33。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数。fun 的花括号中填入所编写的若干语句。
试题程序:
include <stdio. h>
include <conio. h>
float fun (float h )
{
}
main()
{
float a;
clrscr ();
printf ("Enter a: ");
scanf ("%f", &a);
printf("The original data is : ");
printf("%f\n\n", a) ;
printf("The result: %f\n", fun(a) );
}
第4题:
下列给定程序中,函数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);
else
return (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));
}
第5题:
有下列函数定义: fun(float h) { printf("%f,%f\n",h,h*h);) 该函数的类型是( )。
A.int类型
B.float类型
C.void类型
D.函数无类型说明,定义有错
第6题:
有下列函数定义:
A.int类型
B.float类型
C.void类型
D.函数无类型说明,定义有错
第7题:
请编写函数fun(),它的功能是求Fibonacci数列中小于t的最大的一个数,结果由函数返回。其中Fibonacci数列F(n)的定义为
F(0)=0,F(1)=1
F(n)=F(n-1)+F(n-2)
例如:t=1000时,函数值为987。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <math.h>
include <stdio.h>
int fun(int t)
{
}
main()
{
int n;
clrscr();
n=1000;
printf("n=%d, f=%d\n",n, fun(n));
}
第8题:
请完成函数fun( ),它的功能是:求Fibonacc数列中小于t的最大的一个数,结果由函数 0返回。Fibonacc数列F(n)定义为:
F(0)=0,F(1)=1
F(n)=F(n-1)+F(n-2)
例如:t=1000时,函数为987。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在下划线上填入所需的内容。
include<conio.h>
include<stdio.h>
include<math.h>
in fun(int t)
{
int a=l,b=1,c=0,i;
do
{
【 】;
a=b;
b=C;
}
while( 【 】);
c= 【 】;
return C;
}
main()
{
int n;
clrscr();
n=1000;
printf("n=%d,f=%d\n",n,fun(n));
}
第9题:
有下列函数定义: fun(float h) { printf("%f,%f\n",h,h*h);} 该函数的类型是( )。
A.27
B.6
C.25
D.30