题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-05 18:53:51

[填空题]下列给定程序中,函数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));

更多"下列给定程序中,函数fun( )的功能是:根据整型参数m,计算如下公式"的相关试题:

[简答题]改错题 下列给定程序中,函数fun( )的功能是根据整型形参m,计算如下公式的值。 y=1-1/(2×2)+1/(3×3)-1/(4×4)+…+(-1)(m+1)/(m×m) 例如:m中的值为5,则应输出0.838611。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include double fun(int m) { double y=1.0; /**********************found***********************/ int j=1; int i; for(i=2; i<=m; i++) { j=-1*j; /**********************found***********************/ y+=1/(i * i); } return(y); } main( ) { int n=5; clrscr( ); printf("/nThe result is %lf/n" ,fun(n)); }
[填空题]下列给定程序中,函数proc( )的功能是:根据整型形参n,计算如下公式的值: A1=1,A2=1/(5+A1),A3=1/(5+A2), …,An=1/(5+A(n-1)) 例如,若n=10,则应输出0.192582。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main( )函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<conio.h> #include<stdio.h> float proc(int n) { //****found**** int A[100]; A[1]=1; int i; //****found**** for(i=1;i<=n;i++) A[i]=1.0/(5+A[i-1]); return A[n]; } void main( ) { int n; system("CLS"); printf("/nPlease enter n:"); scanf("%d",&n); printf("A%d=%1f/n",n,proc(n)); }

[填空题]下列给定程序中,函数fun( )的功能是:根据整型形参n,计算如下公式的值。
  A1=1,A2=1/(5+A1),A3=1/(5+A2),…,An=1/(5+A(n-1))
例如,若n=l0,则应输出0.192582。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
float fun(int n)
{
/***********found*************/
int A=1;
int i;
/*************found*************/
for(i=1;i<=n;i++)
A=1.0/(5+A);
return A;
}
main( )
{
int n;
clrscr( );
printf("/nPlease enter n:");
scanf("%d",&n);
printf("A%d=%lf/n”,n,fun(n));
}
[填空题]下列给定程序中,函数fun( )的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3,若是等腰三角形,则返回2,若能构成三角形则返回1,若不能,则返回0。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <math. h> int fun(int a, int b, int c) { if (a+b>c&&b+c>a&&a+c>b) { if (a==b&&b==c) /*************found**************/ return 1; else if(a==b|| b==c||a==c) return 2; /*************found**************/ else return 3; } else return 0; } main ( ) { int a,b, c, shape; printf("/nInput a,b,c: "); scanf ("%d%d%d", &a, &b, &c); printf ("/na=%d, b=%d, c=%d/n",a,b,c); shape=fun (a,b, c); printf ("/n/nThe shape : %d/n", shape); }
[填空题]下列给定程序中函数fun的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为87653142时,t中的数为7531。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void fun(long s,long*t)

int d;
long s1=1;
/*********found*********/
t=0;
while(s>0)

d=s%10;
/*********found*********/
if(d%2==0)

*t=d*s1+*t:
s1*=10:

s/=10;


void main( )

long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%id",&s);
fun(s,&t);
printf("The result is:%id/n",t);

[填空题]下列给定程序中函数fun( )的功能是;从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放在t中。例如,当s中的数为4576235时,t中的数为4725。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<conio.h>
/************found*************/
int fun(long s,long *t)

long s1=l0;
*tis%10;
while(s>0)

/*************found*************/
s=s%100;
*t=s%10*s1+*t;
s1=s1*10;


main( )

long s,t;
clrscr( );
printf("/nPlease enter s:");
scanf("%ld",&s);
fun(s,&t);
printf("The result is:%ld/n",t);

[填空题]下列给定程序中函数fun( )的功能是:将长整型数中每一位上为奇数的数依次取出,构成一个新数放在冲。高位仍在高位,低位仍在低位。例如当s中的数为87653142时,t中的数为7531。 请改正函数fun( )中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> #include <conlo.h> void fun (long s, long *t) {int d; long s1=1; /*************found**************/ t=0; while(s>0) { d=s%10; /*************found**************/ if(d%2==0) {*t=d*s1+*t; s1*=10; } s/=10; } } main( ) {long s, t; clrscr( ); printf("/nPlease enter s:");scanf("%ld",&s); fun(s,&t); printf("The result is:%ld/n",t); }
[简答题]下列给定程序中函数fun( )的功能是:从低位开始取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。例如,当s中的数为7654321时,t中的数为642。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include <conio.h>
/*************found**************/
void fun(long s,long t)
long s1=10;
s/=10;
*t=s%10;
/*************found**************/
while(s<0)
s=s/100;
*t=s%10*s1+*t;
s1=s1*10;


main( )
long s, t;
clrscr( );
printf("/nPlease enter s: "); scanf
("%ld",&s);
fun(s,&t);
printf("The result is: %ld/n ",t);

[填空题]下列给定程序中,函数fun( )的功能是:将长整型数中每一位上为偶数的数依次取出,构成一个新数放在冲。高位仍在高位,低位仍在低位。例如,当s中的数为87653142时,t中的数为8642。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main,~数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> void fun(long s,long *t) /**********************************/ { int d; long s1=l; *t=0; while(s>0) { d=s%10; /**********************************/ if(d%2=0) {*t=d*sl+*t; sl*=10 } /**********************************/ s/=10; } } main ( ) { long s,t; clrscr( ); printf("/nPlease enter s: "); scanf ("%ld",&s); fun(s,&t); printf("The result is :%ld/n",t); }
[填空题]给定程序MODl1.C中函数fun的功能是:从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放在t中。高位仍在高位,低位仍在低位。例如:当s中的数为2736598时,t中的数为:2358。 #include<conio.h> #include<stdio.h> /************found************/ void fun(long s,long t) { long s1=10; *t=s%10; while(s>0) { s=s/l00; *t=S%10*s1+*t; /************found************/ s1=s1*100; } } main( ) {long s,t; clrscr( ); printf ("/nPlease enter s:"); scanf("%ld",&s); fun(s,&t); printf("The result is:%1d/n",t); }
[简答题]下列给定程序中,函数fun( )的功能是:根据以下公式求n的值,并作为函数值返回。例如,给指定精度的变量eps输入 0.0005时,应当输出Pi=3.140578。
n/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <math.h>
double fun(double eps)
double s,t; int n=t;
s=0.0;
/*************found**************/
t=1;
/*************found**************/
while(t>eps)
s+=t;
t=t*n/(2*n+1);
n++;

/*************found**************/
return (s);

main( )
double x;
printf("/nPlease enter a precision: ");
scanf("%1f",&x);
printf("/nPi=%1f/n ",fun(x));

[简答题]下列给定程序中,函数fun的功能是:有N×N矩阵,根据给定的m(mc=N)值,将每行元素中的值均向右移动m个位置,左位置为O。例如,N=3,m=2,有下列矩阵:
1 2 3
……
4 5 6
……
7 8 9
程序执行结果为:
0 0 1
……
0 0 4
……
0 0 7
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 4
void fun(inf(*f)[N].int m)

int i,j;
/********found********/
for(i=0;i<N; (1) )

for(j=N-1-m;j>=0;j--)
/********found********/
t[i][j+ (2) ]=[i][j];
/********found********/
for(j=0;j< (3) ;j++)
t[i][j]=0;


main( )

int t[][N]=21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10,i,j,m;
printf("/nThe original array:/n");
for(i=0;i<N;i++)

for(j=0;j<N;j++)
printf("%2d",t[i][j]);
printf("/n");

printf("Input m(m<=%d):"N);
scanf("%d",&m);
fun(t,m);
printf("/nThe result is:/n");
for(i=0;i<N;i++)

fo
[填空题]下列给定程序中,函数fun( )的功能是:找出一个大于给定整数m且紧随m的素数,并作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #include <stdio.h> int fun( int m) { int i,k; for (i=m+1; ;i++) { for (k=2;k<i;k++) /*************found**************/ if (i%k!=0) break; /*************found**************/ if (k<i) return(i); } } main( ) { int n; clrscr ( ); printf("/nPlease enter n: "); scanf ("%d", &n); printf ("%d/n",fun(n)); }

我来回答:

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

订单号:

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