题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-17 07:37:58

[简答题]编写函数,isValue,它的功能是:求以下数列中满足t(K)=1的最小的k,结果由函数返回。其中数列t(n)的定义为:
t(0)=m(m为给定正整数,m<=300)
t(n+1)=t(n)/2 (当t(n)为偶数时)
或t(n+1)=3*t(n)+1(当t(n)为奇数时)
最后调用函数writeDat( )读取50个数据m,分别得出结果且把结果输出到文件out.dar中。
例如:当t=299时,函数值为117。
已知对于m<=300,结果k不超过300
部分源程序已给出。
请勿改动主函数main( )和写函数writeDat( )的内容。
#include<stdio. h>
int jsValue(int m)

main ( )

int m;
m=300;
printf ("m=%d, k-%d/n", m, jsValue (m));
writeDat ( );
writeDat ( )

FILE *in, *out;
int i,m,s;
in= fopen ( "in. dar" , "r" );
out=f open ( "out. dar" , "w" );
for (i=0; i<50; i++)
fscanf (in, "%d", &m);
s=jsValue (m);
printf( "%d/n", s );
fprintf (out, "%d/n" , s );

fclose (in);
fclose (out);

更多"编写函数,isValue,它的功能是:求以下数列中满足t(K)=1的最"的相关试题:

[简答题]编写函数fun,其功能是:求Fibonacci数列中大于t的最小的数,结果由函数返回。Fibonacci数列F(n)的定义为:
F(0)=0,F…=1
F(n)=F(n-1)+F(n-2)
例如,当t=1000时,函数值为1597。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<conio.h>
#include<math.h>
#include<scdio.h>
int fun(int t)


main( )

int n;
n=1000;
printf("n=%d,f=%d/n",n,fun(n));

[简答题]编写函数jsValue( ),其功能是:求Fibonacci数列中大于t的最小的一个数,结果由函数返回。其中Fibonacci数列F(n)的定义为:
F(0)=0,F(1)=1
F(n)=F(n-1)+F(n-2)
最后调用函数writeDat( )从in.dat中读取50个数据t,分别得出结果,且把结果输出到out.dat文件中。
例如:当t=1000时,函数值为:1597。
注意:部分程序已经给出。
请勿改动主函数main( )和写函数writeDat( )的内容。
#include<Stdio.h>
int jsValue(int t)


void writeDat( )

FILE *in,*out;
int i,n,s;
in=fopen("in.dat","r");
out=fopen("out.dat","w");
for(i=0;i<50; i++)

fscanf(in,"%d,",&n);
S=jsValue(n);
fprintf(out,"%d/n",s);

fclose(in);
fclose(out);

main( )

int n;
n=1000;
printf("t=%d,f=%d/n",n,jsValue(n));
writeDat( );

[简答题]编写函数jsValue( ),它的功能是求Fibonacci数列中大于t的最小的一个数,结果由函数返回,其中Fibonacci数列F(n)的定义为:F(0)=0,F(1)=1F(n)=F(n-1)+F(n-2)最后调用函数writeDat( ),把结果输出到文件OUT10.DAT中。例如:当t = 1000时,函数值为1597。注意:部分源程序已给出。请勿改动主函数main( )和写函数WriteDat( )的内容。试题程序:#include int jsValue(int t){ }main( ){int n;n=1000;printf("n=%d, f=%d/n", n, jsValue(n));writeDat( );}writeDat( ){FILE *in, *out;int n,s;out = fopen("OUT10.DAT", "w");s = jsValue(1000); printf("%d",s);fprintf(out, "%d/n", s);fclose(out);}
[简答题]请编写函数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));

[简答题]编程题请编写函数fun( ),它的功能是求Fibonacci数列中小于t的最大的一个数,结果由函数返回。其中Fibonacci数列F(n)的定义为F(0)=0,F(1)=1F(n)=F(n-1)+F(n-2)例如:t=1000时 ,函数值为987。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:#include #include #include int fun(int t){}main( ){ int n; clrscr( ); n=1000; printf("n=%d, f=%d/n",n, fun(n));}
[简答题]规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函数时,不得使用C语言提供的字符串函数。
例如,字符串中的内容为“****A*BC*DEF*G*******”,删除后,字符串中的内容应当是“ABCDEFG”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
void fun(char*a)


voidmain( )

char s[81];
printf("Enter a string:/n");
gets(s);
fun(s);
printf("The string after delete&/n");
puts(s);

[简答题]编写函数fun( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)
例如:若n的值为11时,函数的值为1.833333。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
float fun(int n)

main( )

int n;
float s;
clrscr( );
printf("/nPlease enter N: ");
scanf("%d",&n);
s=fun(n);
printf("The result is:%f/n " , s);

[简答题]请编写函数fun( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int fun( int a [M][N])

main( )

int aa[M][N]=1,3,5,7,9,2,9,9,9,4,
6,9,9,9,8,1,3,5,7,0;
int i, j, y;
clrscr( );
printf ("The original data is :/n ");
for(i=0; i<N;i++)
for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("/n ");

y=fun(aa);
printf("/nThe sun:%d/n ",y);
printf("/n");

[简答题]请编写函数proc( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。 例如,有6门课程的成绩是90.5,72,80,61.5,55,60,则函数的值为69.83。 注意:部分源程序给出如下。 请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的花括号中填入所编写的若干语句。 试题程序: #include<stdio.h> float proc(float*a,int n) { } void main( ) { float score[30]={90.5,72,80,61.5,55,60}, aver; aver=proc(score,6); 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); }
[简答题]下列程序定义了NXN的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a数组中的值为 a=0 1 2 7 9 1 11 21 5 5 2 21 6 11 1 9 7 9 10 2 5 4 1 4 1 则返回主程序后s的值应为310。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio.h> #include<conio.h> #include<stdlib.h> #define N 5 int fun (int w[][N]) { } main( ) { int a[N][N]={0,1,2,7,9,1,11,21,5,5,2, 21,6,11,1,9,7,9,10,2,5,4,1,4,1}; int i,j; int s; clrscr( ); printf("*****The array***+*/n"); for (i=0;i<N;i++) { for(j=0;j<N;i++) {printf("%4d",a[i][j]);} printf("/n"); } s=fun(a); printf("*****THE RESULT*****/n"); printf("The sum is:%d/n",s); }
[多项选择]编程题 下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a 数组中的值为 a=0 1 2 7 9 1 11 21 5 5 2 21 6 11 1 9 7 9 10 2 5 4 1 4 1 则返回主程序后s的值应为310。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include #include #include #define N 5 int fun (int w[][N]) { } main( ) { int a[N][N]={0,1,2,7,9,1,11,21,5,5,2,21,6,11,1,9,7,9,10,2,5,4,1,4,1}; int i, j; int s; clrscr( ); printf("*****The array*****/n "); for (i=0; i

我来回答:

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

订单号:

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