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

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

更多"下列给定程序中函数fun( )的功能是:计算n!。例如,给 n输入5,"的相关试题:

[填空题]下列给定程序中函数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)); }
[填空题]下列给定程序中,函数fun的功能是:计算N×N矩阵的主对角线元素和反向对角线元素之和,并作为函数值返回。要求先累加主对角线元素中的值,再累加反向对角线元素中的值。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 4
fun(int t[][N], int n)

int i, sum;
/******************found*******************/
(1) ;
for(i=0; i<n; i++)
/******************found*******************/
sum+= (2) ;
for(i=0; i<n; i++)
/水半丰拳术水术枣木车术木木水丰半术fbund木木木水串术半半术术术半术丰木丰年,
sum+=t[i][n-i- (3) ;
return sum;

main( )

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

for(j=0; j<N; j++)
printf("%4d", t[i][j]);
printf("/n");
printf("The result is:%d", fun(t, N));


[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。 例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。 注意:部分源程序给出如下. 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio.h> float fun (float *a, int n) { } main ( ) { float score[30]=(90.5,72,80,61.5,55}, aver; aver=fun(score, 5); printf("/nAverage score is: %5.2f /n",aver); }
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)


main ( )

float score[30]=(90.5,72,80,61.5,55,
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);

[填空题]下列给定程序中函数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( )的功能是:给一维数组a输入任意4个整数,并按如下的规律输出。例如输入1,2,3,4,程序运行后输出以下方阵:
4 1 2 3
3 4 1 2
2 3 4 1
1 2 3 4
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main 函数,不得增行或删行,也不得更改程序的结构。
试题程序;
#include <stdio.h>
#define M 4
/*******************************/
void fun(int a)
int i,j,k,m;
printf("Enter 4 number: ");
for (i=0; i<M; i++) scanf ("%d", &a [i] );
printf ("/n/n The result : /n/n ");
for (i=M; i>0; i--)
k=a [M-1];
for (j=M-1; j>0; j--)
/**********************************/
a[j]=a[j+1];
a[0]=k;
for (m=0 ;m<M; m++ ) printf ("%d ", a [m]);
printf ("/n ");


main ( )
int a [M];
fun(a); printf("/n/n ");

[简答题]下列给定程序中函数fun的功能是:计算正整数num各位上的数字之积。
例如,若输入252,则输出应该是20。若输入202,则输出应该是0。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <conio.h>
long fun(long mum)

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

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

main( )

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

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

[填空题]给定程序中,函数fun( )的功能是:求输入的两个数中较小的数。 例如:输入5 10,结果为min is 5。 请改正fun( )程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序、 #include <stdio. h> #include<conio. h> /*************found**************/ int fun(int x, y) { int z; z=x<yx: y; return (z); } main ( ) {int a,b,c; scanf ("%d, %d/n", &a, &b); c=fun (a, b); printf ("min is %d", c); }
[填空题]下列给定程序中函数fun( )的功能是计算1/n!的值。 例如:给n输入5,则输出0.0083330 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> #include <conio.h> /******+****found*************/ int fun(int n) { double result=1.0; if(n==0) return 1.0; while(n>1 && n<170) /**********found************/ result *=n++; result=1/result; return result; } main( ) { int n; printf("Input N:"); scanf("%d",&n); printf("/n1/%d!=%If/n",n,fun(n)); }
[填空题]下列给定程序中函数fun( )的功能是计算1/n!的值。
例如:给n输入5,则输出0.0083330
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
/******+****found*************/
int fun(int n)
double result=1.0;
if(n==0)
return 1.0;
while(n>1 && n<170)
/**********found************/
result *=n++;
result=1/result;
return result;
main( )

int n;
printf("Input N:");
scanf("%d",&n);
printf("/n1/%d!=%If/n",n,fun(n));

我来回答:

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

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码