题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-22 12:26:09

[填空题]下列给定程序中,函数 fun( ) 的功能是:计算并输出下列级数的的N项之和SN,直到SN+1大于q为止,q的值通过形参传入。 SN=2/1+3/2+4/3+(N+1)/N 例如,若q的值为50.0,则函数值为49.394948。 请改正程序中的错误,使它能得出正确的结果。 注意;不要改动main 函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #include <stdio. h> /**************found***************/ double fun(double q) { int n; double s,t; n=2; s=2.0; while (s<=q) { t=s /*************found *************/ s=s+ (n+1)/n; n++; } printf ("n=%d/n ", n); /************found***************/ return s; } main ( ) { clrscr( ); printf ("%f/n ",fun (50)); }

更多"下列给定程序中,函数 fun( ) 的功能是:计算并输出下列级数的的N"的相关试题:

[填空题]下列给定程序中,函数 fun( ) 的功能是:计算并输出下列级数的的N项之和SN,直到SN+1大于q为止,q的值通过形参传入。
SN=2/1+3/2+4/3+(N+1)/N
例如,若q的值为50.0,则函数值为49.394948。
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main 函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#include <stdio. h>
/**************found***************/
double fun(double q)
int n; double s,t;
n=2;
s=2.0;
while (s<=q)

t=s
/*************found *************/
s=s+ (n+1)/n;
n++;

printf ("n=%d/n ", n);
/************found***************/
return s;

main ( )
clrscr( );
printf ("%f/n ",fun (50));

[填空题]下列给定程序中,函数fun( )的功能是:求出以下分数序列的前n项之和。 2/1,3/2,5/3,8/5,13/8,21/13,…… 和值通过函数值返回main( )函数。例如,若输入n=5,则应输出8.391667。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> /*************found**************/ fun (int n) { int a=2,b=l,c, k; double s=0.0; for(k=l;k<=n;k++) {s=s+l.0*a/b; /*************found**************/ c=a; a+=b; b+=c; } return (s); } main ( ) { int n=5; clrscr ( ); printf("/nThe value of function is: %1f/n", fun (n)); }
[简答题]下列给定程序中,函数fun的功能是:计算正整数num各位上的数字之积。
注意:不要改动maln函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h >
#include <conio.h>
long fun (long num)

/********** found********** /
long k;
do

k*=num% 10;
/********** found********** /
num/=10;
while (num);
return (k);

main ( )

long n;
printf ("/ n please enter a num-
ber: ");
scanf("% 1d", &n);
printf("/n% 1d/n", fun(n));

[简答题]改错题 下列给定程序中,函数fun( )的功能是计算并输出high以内的素数之和。high由主函数传给fun( )函数。若high的值为100,则函数的值为1060。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include #include int fun(int high) { int sum=0,n=0, j, yes; while(high>=2) { yes = 1; for(j=2; j<=high/2; j++) /**********************found***********************/ ifhigh%j==0 { yes=0; break; } /**********************found***********************/ if(yes==0) { sum+=high; n++; } high--; } return sum; } main( ) { clrscr( ); printf("%d/n",fun(100)); }
[简答题]下列给定程序中,函数fun( )的功能是计算并输出 high以内的素数之和。high由主函数传给fun( )函数。
例如:若high的值为100,则函数的解为1060。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<conio.h>
#include<stdio.h>
#include<math.h>
int fun(int high)

int sum=0,n=0,j,yes;
while(high>=2)

yes=1;
for(j=2;j<=high/2;j++)
/**********************found***********************/
ifhigh%j==0

yes=0;
break;

/***********************found***********************/
if(yes==0)

sum+=high;
n++;

high--;

return sum;

main( )

clrscr( );
printf("%d/n",fun(100));

[简答题]下列给定程序中,函数fun( )的功能是计算并输出high以内的素数之和。high由主函数传给fun( )函数。
例如:若high的值为100,则函数的返回值为1060。
请改正程序中的错误,使它能得到正确结果。
[注意] 不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include <conio.h>
#include <stdio.h>
#include<math.h>
int fun(int high)

int sum=0, n=0, j, yes;
while(high>=2)

yes=1;
for(j=2;j<=high/2; j++)
**********************found**********************/
ifhigh%j==0

yes=0;
break;

/**********************found**********************/
if(yes==0)

sum+=high;
n++;

high--;

return sum;

main( )

clrscr( );
printf("%d/n", fun(100));

[简答题]下列给定程序中,函数fun的功能是:计算并输出high以内最大的10个素数的和。high的值由主函数传给fun函数。
例如,若high的值为10。,则函数的值为732。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<scdio.h>
#include<math.h>
int fun(int high)

int sum=0,n=0,j,yes;
/********found********/
while((high>=2)&&(n<10)

yes=1;
for(j=2;j<=high/2;j++)
if(high%j==0)

/********found********/
yes=0;break

if(yes)

sum+=high;
n++;

high--;

return sum;

main( )

printf("%d/n",fun(100));

[填空题]由N个有序整数组成的数列已放在一维数组中,下列给定程序函数fun的功能是:利用折半查找法查找整数m在数组中的位置。若找到,返回其下标值;否则,返回-1。
折半查找的基本算法是:每次查找前先确定数组中待查的范围low和high(low<high),然后用m与中间位置(mid)上元素的值进行比较。如果m的值大于中间位置元素的值,则下一次的查找范围落在中间位置之后的元素中;反之,下一次的查找范围落在中间位置之前的元素中,直到low>high,查找结束。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 10
/**********found**********/
void fun(int a[],int m)
int low=0,high=N-1,mid;
while(low<=high)
mid=(low+high)/2;
if(m<a[mid])
high=mid-1;
/********found**********/
else if(m>a[mid])
low=mid+1;
else return(mid);

return(-1);

void main( )
int i,a[N]=(-3,4,7,9,13,45,67,89,100,180),
k,m;
printf("a数组中的数据如下:");
for(i=0;i<N;i++)
printf("%d",a[i]);
printf("Enter m:");
scanf("%d",&m);
k=fun(a,m);
if(k>=0)
printf("m=%d,index=%d/n",m,k);
else printf("Not be found /n");

[简答题]改错题 下列给定程序中函数fun( )的功能是计算正整数num的各位上的数字之平方和。 例如:输入352,则输出应该是38;若输入328,则输出应该是77。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include long fun(long num) { /**********************found***********************/ long k=1; do { k+=(num%10)*(num%10); num/=10; /**********************found***********************/ }while(num) return (k); } main( ) { long n; clrscr( ); printf("/Please enter a number:"); scanf("%ld",&n); printf("/n%ld/n",fun(n)); }
[填空题]下列给定程序中函数fun( )的功能是计算正整数num的各位上的数字之平方和。
例如:输入352,则输出应该是38;若输入328,则输出应该是77。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
long fun(long num)

/*+**+*+*+*found************/
long k=1;
do

k+=(num%10)*(num%10);
num/=10;
/*********+found*+**+*+******/
while(num)
return(k);
main( )

long n;
clrscr( );
printf("/Please enter a number:");
scanf("%ld",&n);
printf("/n%ld/n",fun(n));

[简答题]下列给定程序中,函数fun的功能是:计算整数n的阶乘。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdlib.h>
#include <stdio.h>
double fun(int n)
double result=1.0;
while(n>1&&n<170)
/******************found*******************/
result*=--n;
/******************found*******************/
Return;

void main( )
int n;
system("CLS");
printf("Enter an integer:");
scanf("%d", &n);
printf("/n/n%d!=%1dn/n", n, fun(n));

[填空题]下列给定程序中函数fun( )的功能是:计算n!。例如,给 n输入5,则输出120.000000。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> #include <conio.h> double fun (int n) { double result=l.0; /*************found**************/ if n==0 return 1.0; while (n>l&&n<170) /*************found**************/ result *=n-- return result; } main ( ) { int n; printf ("Input N: "); scanf ( "%d" &n); printf ("/n/n%d!=%lf/n/n",n, fun(n)); }

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码