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

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


main( )

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

更多"下列给定程序中函数fun的功能是:把从主函数中输入的3个数,最大的数放"的相关试题:

[填空题]下列给定程序中函数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的功能是:把从主函数中输入的3个数,最大的数放在a中,中间的数放在b中,最小的数放在c中。
例如,若输入的数为:55 12 34,输出的结果应当是:a=55.0,b=34.0,c=120。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动: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;


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的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在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中的数为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); }
[简答题]给定一个函数,其函数功能为:使10个整数按由小到大的顺序排列。在主函数中输入10个数,并输出结果。使用VC6打开考生文件夹下的工程RevProj5。此工程包含一个源程序文件RevMain5.cpp,该程序实现上述功能。但此程序运行有问题。请找出错误的地方,改正后将此程序调试正确。
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main( )

void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers/n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)

if((p-&data[0]) %5==0)
cout<<" /n";
cout<<setw (5) <<*p;

sort (data, 10);
cout<<"/n the present array is:";
for(p=data;p〈data+10;p++)

if((p-&data[0])%5==0) cout<<"/n";
cout<<setw (5)<<*p;


void sort(int array[],int n)

/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)

for (p2=p1+1 ;p2<array+n;p
[填空题]下列给定程序中,函数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);

[简答题]在主函数中从键盘输入若干个数放人数组中,用0结束输入并放在最后一个元素中。下列给定程序中,函数fun的功能是:计算数组元素中所有值为正数的平均值(不包括0)。
例如,数组中元素的值依次为:39、-47、21、2、-8、15、0,则程序的运行结果为19250000。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<conio.h>
#include<scdio.h>
double fun(int x[])

/********found********/
int sum=0.0;
int c=0,i=0;
while(x[i]!=0)

if(x[i]>0)

sum+=x[i];
C++;

i++;
]
/********found********/
sum/=c;
return sum;

main( )

int x[1000];
int i=0;
printf("/nPlease enter some dat a(endwith 0):");
do

scanf("%d",&x[i]);

while(x[i++]!=0);
printf("%lf/n",fun(x));

[填空题]在主函数中从键盘输入若干个数放入数组中,用0结束输入并放在最后一个元素中。下列给定程序中,函数fun( )的功能是计算数组元素中值为负数的平均值(不包括0)。
例如:数组中元素的值依次为43,47,-21,53,-8,12, 0,则程序的运行结果为-25.333333。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
double fun(int x[])

double sum=0.0;
int c=0,i=0;
/*************found*************/
while(x[i]==0)

if(x[i]<0)

sum=sum+x[i];
c++;

i++;

/************found***********/
sum=sum/c;
return sum;
main( )

int x[1000];
int i=0;
clrscr( );
printf("/nPlease enter some data(end with
0) :”);
do

scanf("%d",&x[i]);
while(x[i++]!=0);
printf("%f/n",fun(x));

[填空题]在主函数中,从键盘输入若干个数放入数组x中,用0结束输入但不计入数组。下列给定程序中,函数fun( )的功能是:输出数组元素中小于平均值的元素。请补充函数fun( )。 例如:数组中元素的值依次为1,2,2,12,5,15,则程序的运行结果为1,2,2,5。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include<conio.h> #include<stdio.h> void fun( 【1】 ,int n) { double sum=0.0; double average=0.0; int i=0; for(i=0;i<n;i++)  【2】 ; average= 【3】 ; for(i=0;i<n;i++) if(x[i]<average) { if(i%5==0) printf("/n"); printf("%d/",x[i]); } } main( ) { int x[1000]; int i=0; clrscr( ); printf("/nPlease enter some data(end with 0):"); do { scanf("%d",&x[i]); } while(x[i++]!=0); fun(x,i-1); }
[简答题]下列给定程序中,fun( )函数的功能是:求3个数的最小公倍数,例如,给变量a、b、c、分别输入15、11、2,则输出结果应当是330。 请修改函数中的错误,得出正确的结果。 注意:不要改动main( )函数,不能增行或减行,也不能更改程序的结构。 试题程序: #include<stdio.h> int fun(int x, int y, int z) { int i, temp, n, m; //****found**** i=1; temp=m=n=1; //****found**** while(temp!=0&&m!=0&&n!=0) { i=i+1; temp=i%x; m=i%y; n=i%z; } return i; } void main( ) { int a, b, c, i; printf("Input a b c: "); scanf("%d%d%d", &a, &b, &c); printf("a=%d, b=%d, c=%d/n", a, b, c); i=fun(a, b, c); printf("The minimal common multiple is: %d/n", i); }

[填空题]以下程序的功能是:通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结 束标志。请填空。 #include long 【 】 ;/* 函数说明语句 */ main( ) {long n; n=func( );printf("n=%1d/n",n); } long func( ) { long m; for(m=0;getchar( )!=@;【 】); return m; }
[填空题]下列程序的功能是通过函数func输入字符并统计输入字符的个数。输入时用字符@作为输入结束标志,请填空。
#include<stdio.h>
long______;/*函数说明语句*/
main( )
long n;
n=func( );printf("n=%1d/n",n);

long func( )
long m;
for(m=0;getchar( )!=’@’;______);
return m;

[填空题]以下程序的功能是:通过函数func输入字符并统计输入字符的个数,输入时用字符@作为输入结束标志。请填空。
#include<stdio.h>
long______; /*函数说明语句*/
main( )
long a;
a=func( ); printf("n=%1d/n", a);

long func( )
long b;
for(b=0; getchar( )!=’@’; b++; );
return b;

[填空题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
int fun (char *s, char *t)
int n; char *p, *r;
n=0;
while(*s)
p=s;
r=t;
while (*r)
/**************found**************/
if(*r==*p) r++; p++
else break;
/*************found**************/
if(r==’/0’)
n++;
s++;

return n;

main( )
char s[100], t[100]; int m;
clrscr( );
printf("/nPlease enter string s: ");
scanf ("%s",s);
printf("/nPlease enter substring t: ");
scanf ("%s",t);
m=fun (s,t);
printf("/nThe result is: m=%d/n", m);

我来回答:

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

订单号:

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