更多"下列给定程序中,函数fun的功能是:把从主函数中输入的3个数,最大的数"的相关试题:
[简答题]下列给定程序中,函数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( )的功能是:将长整型数中每一位上为偶数的数依次逆向取出,构成一个新数放在t中。高位在低位,低位在高位。例如当s中的数为25846513时,t中的数为6482。
请改正函数fun( )中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
void fun(long s,long *t)
int d;
long sl=l,i=1;
*t=0;
while(s/i>0)
i=i*10;
i=i/10;
while(s>0)
d=s/i
/*************found*************/
if(d%2!=0)
/*************found*************/
t=d*sl+t;
sl*=l0;
s=s%i;
i=i/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>
/************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;
msin( )
long s, t;
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>
/************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;
mein( )
long s,t;
printf("/nPlease enter s:");
scanf("%1d",&s);
fun(s,&t);
printf("The result is:%1d/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);
[填空题]给定程序MODI1.C中函数fun的功能是:将长整型数中为偶数的位依次取出,构成一个新数放在t中。高位仍在高位,低位仍在低位。例如,当s中的数为87653142时,t中的数为8642。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
void fun(10ng s,long *t)
int d;
long s1=1;
t=0;
while(s>0)
d=s%10:
/**********found**********/
if(d%2=0)
*t=d*s1+*t; s1*=10;
/**********found**********/
s/=10;
void main( )
long s,t;
printf("/nPlease enter s:");
seanf("%1d",&s);
fun(s,&t);
printf("The result is:%1d/n",t);
[填空题]在主函数中,从键盘输入若干个数放入数组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的功能是:统计所有小于等于n(n>2)的素数的个数,素数的个数作为函数值返回。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
int fun(int n)
int i,j,cnt=0;
printf("/nThe prime number between 3 to%d/n",n);
for(i=3;i<=n;i++)
/**********found**********/
for( (1) ;j<i;j++)
/**********found**********/
if( (2) %j==0)break;
/**********found**********/
if( (3) >=i)
cnt++;printf(cnt%157"%5d":"/n%5d",i);
return ent;
void main( )
int n=20,r;
r=fun(n);
printf("/nThe number of prime is:%d/n",r);