题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-09 19:00:07

[填空题]下列给定的程序中,函数hn( )的功能是:为一个偶数寻找两个素数,这两个素数之和等于该偶数,并将这两个素数通过形参指针传回主函数。 请改正函数fun( )中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> #include <math.h> void fun(int a, int *b, int *c) { int i,j,d,y; for (i=3;i<=a/2;i=i+2) /*************found**************/ {y=0; for (j=2;j<=sqrt((double)i);j++) if (i%j==0) y=0; if (y==1) /*************found**************/ { d=i-a; for (j-2;j<=sqrt((double)d); j++) if (d%j==0) y=0; if (y=-1) {*b=i; *c=d;} } } } main ( ) { int a,b,c; do { printf("/nInput a: "); scanf ("%d", &a); } while (a%2); fun (a, &b, &c); printf ("/n/n%d=%d+%d/n", a,b,c); }

更多"下列给定的程序中,函数hn( )的功能是:为一个偶数寻找两个素数,这两"的相关试题:

[填空题]下列给定的程序中,函数hn( )的功能是:为一个偶数寻找两个素数,这两个素数之和等于该偶数,并将这两个素数通过形参指针传回主函数。
请改正函数fun( )中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <math.h>
void fun(int a, int *b, int *c)
int i,j,d,y;
for (i=3;i<=a/2;i=i+2)
/*************found**************/
y=0;
for (j=2;j<=sqrt((double)i);j++)
if (i%j==0) y=0;
if (y==1)
/*************found**************/
d=i-a;
for (j-2;j<=sqrt((double)d);
j++)
if (d%j==0) y=0;
if (y=-1)
*b=i; *c=d;



main ( )
int a,b,c;
do
printf("/nInput a: ");
scanf ("%d", &a);
while (a%2);
fun (a, &b, &c);
printf ("/n/n%d=%d+%d/n", a,b,c);

[填空题]下列给定程序中,函数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)); }
[简答题]下列给定程序中,函数fun的功能是:求两个非零正整数的最大公约数,并作为函数值返回。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(int a, int b)
int r, t;
if(a<b)
t=a; b=a; a=t;
/******************found*******************/

r=a%b;
while(r!=0)
a=b; b=r; r=a%b;
/******************found*******************/
return(a);

void main( )
int num1, num2, a;
printf("Input num1 num2:");
scanf("%d%d", &num1, &num2);
printf("num1=%d num2=%d/n/n", num1, num2);
a=fun(num1, num2);
printf("The maximun common divisor is%d/n/n",a);

[简答题]下列给定程序中,函数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的功能是:把从主函数中输入的3个数,最大的数放在a中,中间的数放在b中,最小的数放在C中。
例如,若输入的数为:55 12 34,输出的结果应当是.a=55.0,b=34.0,c=12.0。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(float*a,float*b,float*c)

/*********found*********/
float*k;
if(*a<*b)

k=*a:
*a=*b:
*b=k;

/*********found*********/
if(*a>*c)

k=*c:
*c=*a:
*a=k;

if(*b<*c)
k=*b;
*b=*c;
*c=k;


void main( )

float a,b,c;
printf("Input a b c:");
scanf("%f%f%f",&a,&b,&c);
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n",a,b,c);
fun(&a,&b,&c);
printf("a=%4.1f,b=%4.1f,c=%4.1f/n/n",a,b,c);

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

[简答题]给定程序中,函数fun的功能是将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用库函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include #include void fun(char *s, int a, double f) { /**********found**********/ __1__ fp; char str[100], str1[100], str2[100]; int a1; double f1; fp = fopen("file1.txt", "w"); fprintf(fp, "%s %d %f/n", s, a, f); /**********found**********/ __2__ ; fp = fopen("file1.txt", "r"); /**********found**********/ fscanf(__3__,"%s%s%s", str, str1, str2); fclose(fp); a1 = atoi(str1); f1 = atof(str2); printf("/nThe result :/n/n%s %d %f/n", str, a1, f1); } main( ) { char a[10]="Hello!"; int b=12345; double c= 98.76; fun(a,b,c); }
[填空题]下列给定程序中,函数fun( )的功能是:给定n个实数,输出平均值,并统计平均值以上(含平均值)的实数个数。例如, n=8时,输入193.199,195.673,195.757,196.051,196.092, 196.596,196.579,196.763,所得平均值为195.838745,在平均值以上的实数个数应为5。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> int fun(float x[], int n) /***************found*******************/ iht j, c=0;float xa=0.0; for (j=0; j<n;.j++) xa+=x[j]/n; printf("ave=%f/n",xa); for (j=0; j<n;j++) if(x[j]>=xa) c++; returnc; } main( ) {float x[l00]={ 193.199,195.673,195.757, 196.051,196.092,196.596, 196.579,196.763}; clrscr ( ); printf("%d/n",fun (x,8)); }
[填空题]给定程序中,函数fun( )的功能是将形参给定的字符串、整数、浮点数写到文本文件中,再用字符方式从该文本文件中逐个读入并显示在终端屏幕上。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
#include <stdio.h>
void fun(char *s,int a,double f)

/**********found**********/
(1) fp;
char ch;
fp=fopen("file1.txt","w");
fprintf(fp,"%s%d%f/n",s,a,f);
fclose(fp);
fp=fopen("file1.txt","r");
printf("/nThe result:/n/n");
ch=fgetc(fp);
/**********found**********/
while(!feof( (2) ))
/**********found**********/
putchar( (3) );ch=fgetc(fp);)
putchar(’/n’);
fclose(fp);

main( )
char a[10]="Hello!";int b=12345;
double c=98.76;
fun(a,b,c);

[简答题]改错题 下列给定程序中,函数fun( )的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。 例如:输入dafhc,则应输出hfdca。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include #include /**********************found***********************/ int fun(char t[ ]) { char c; int i,j; for(i=0;i
[简答题]下列给定程序中,函数fun的功能是:求两个非零正整数的最大公约数,并作为函数值返回。
例如,若num1和num2分别为49和2l,则输出的最大公约数为7;若num1和num2分别为27和81,则输出的最大公约数为27。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(int a,int b)

int r,t;
if(a<b)
/********found********/
(t=a;b=a;a=t;)
r=a%b;
while(r!=0)
(a=b;b=r;r=a%b;)
/********found********/
return(a);

void main( )

int num1,num2,a;
printf(Input num1 num2:");
scanf("%d%d",&num1,&num2);
printf("num1=%d num2=%d/n/n",num1,num2);
a=fun(num1,num2);
printf("The maximun common divisor is%d/n/n",a);

我来回答:

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

订单号:

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