更多"请补充函数fun( ),该函数的功能是:把从键盘输入的3个整数按从小到"的相关试题:
[填空题]请补充函数fun( ),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如:输入“33 78 25”,结果输出“25 33 78”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
# include<conio. h>
main( )
int x,y, z,t;
clrscr ( );
printf ("Input x, y, z/n");
scanf ("%d%d%d", &x, &y, &z);
if( 【1】 )
t=x;
x=y;
y=t;
/*变换x, y的值*/
if( 【2】 )
t=z;
z=x;
x=t;
/*交换x, z 的值*/
if( 【3】 )
t=y;
y=z;
z=t;
/*变换 z, y 的值*/
printf("******the result*******/n");
printf("from small to big: %d %d %d/n",
x, y, z);
[填空题]请补充fun( )函数,该函数的功能是求m的阶乘。不要改动主函数main( )与他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式或语句。
注意:部分源程序如下。
#include<stdio.h>
long fun(int m)
if (1)
return(m*fun (2) );
return (3) ;
main( )
printf("8!=%ld/n",fun(8));
[填空题]请补充fun函数,fun函数的功能是求n的阶乘。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句
试题程序:
#include<stdio.h>
long fun(int n)
if( (1) )
return(n*fun( (2) ));
return (3) ;
main( )
printf("10!=%1d/n",fun(10));
[填空题]fun1函数的功能是将3个整数按由大到小的顺序调整后依次放入a、b、c3个变量中,a中放最大数,fun2函数的功能是交换两个变量中的值。补足所缺语句。
fun2(int*x,int*y)
int t;
t=*x;*x=*y;*y=t;
fun1(int*p1,int*p2,int*p3)
if(*p3>*p2) fun2(*P2,*p3);
if(*p1<*p3) fun2(______);
if(*p1<*p2) fun2(______);
main( )
int a,b,c;
scanf("%d%d%d",&a,&b,&c) ;
fun1(&a,&b,&c) ;
printf("%d,%d,%d/n",a,b,c) ;
[填空题]请补充fun函数,该函数的功能是:判断一个年份是否为闰年。
例如,1900年不是闰年,2004是闰年。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
int fun(int n)
int flag=0;
if(n%4==0)
if( (1) )
int year;
printf("Input the year:");
scanf("%d",&year);
if(fun(year))
flag=1;
if( (2) )
flag=1;
return (3) ;
rnain( )
printf("%d is a leap year./n",year);
else
printf("%d is not a leap year./n",year);
[填空题]请补充fun函数,该函数的功能是:把字符的ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串中,字符串str从键盘输入,其长度作为参数传入fun函数。
例如,输入“abcdef”则输出“bdf”。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 100
void (1)
int i,j;
(2) ;
for(i=0;i<n;i++)
char str[N];
printf("please input a string:/n");
gets(str);
while(str[i]!=’/0’)
len++;
if(s[i]%2==0)
s[j++]=s[i];
(3) ;
main( )
int i=0,len=0;
i++;
fun(str,len);
printf("The result string:/n");
puts(str);
[填空题]请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。
例如: 当str1=“cdef",str2=“cde”时,函数fun( )返回“>”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
# include< stdio, h>
#include<conio. h>
#define N 80
char *fun (char *str1,char *str2)
{
char *p1=str1, *p2=str2;
while (*p1 & & *p2 )
{
if ( 【1】 )
return "<";
if( 【2】 )
return ">";
p1++;
p2++;
}
if (*p1=*p2)
return "==";
if (*p1== 【3】 )
return "<";
else
return ">";
}
main( )
{
char str1 [N], str2 [N];
clrscr ( );
printf ("Input str1: /n");
gets (str1);
printf ("Input str2: /n");
gets (str2);
printf ("/n*****the result*****/n");
printf ("/nstr1 %s str2", fun (str1, str2) );
}
[填空题]请补充fun函数,该函数的功能是:将带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的行线上填入所编写的若干表达式或语句。
[试题源程序]
#include<stdio.h>
#include<stdlib.h>
#define N 5
typedef struct node
int data;
struct node * next;
NODE;
void fun(NODE * h)
NODE*P,*q,*r;
p= (1) ;
if( (2) )return;
q=p->next;
p->next=NULL;
while(q)
r=q->next;
q->next=p;
p=q;
q= (3) ;
h->next=p;
NODE*creatlist(int a[])
NODE*h.*p,*q;int i;
h=(NODE*)malloc(sizeof(NODE));
h->next=NULL;
for(i=0;i<N;i++)
q=(NODE*)malloc(sizeof(NODE));
q->data=a[i];
q->next=NULL;
if(h->next==NULL)
h->next=p=q;
else
P->next=q;p=q;
return h;
void outlist(NODE*h)
NODE*P;
p=h->next;
if(p==NULL)
printf("The list is NULL!/n");
[填空题]请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。
例如: 当str1=“cdef",str2=“cde”时,函数fun( )返回“>”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
# include< stdio, h>
#include<conio. h>
#define N 80
char *fun (char *str1,char *str2)
char *p1=str1, *p2=str2;
while (*p1 & & *p2 )
if ( 【1】 )
return "<";
if( 【2】 )
return ">";
p1++;
p2++;
if (*p1=*p2)
return "==";
if (*p1== 【3】 )
return "<";
else
return ">";
main( )
char str1 [N], str2 [N];
clrscr ( );
printf ("Input str1: /n");
gets (str1);
printf ("Input str2: /n");
gets (str2);
printf ("/n*****the result*****/n");
printf ("/nstr1 %s str2", fun (str1, str2) );