更多"[函数2.1说明] 下面程序的功能是计算x和y的最小公倍数。[函数2"的相关试题:
[简答题][函数2.1说明]
下面程序的功能是计算x和y的最小公倍数。
[函数2.1]
main( )
{ int m,n,d,r;
seanf("%d %d",&m,&n);
if(m<n) {r=m;m=n;n=r;}
(1) ;
while (d%n! =0) (2) ;
printf("%d/n",d);
}
[函数2.2说明]
下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。
[函数2.2]
#include <stdio.h>
main( )
{ char c,preChar=’/0’;
c = getchar( );
while(c! = ’.’){
if( (3) ) putchar(c);
else if(preChar! =’ ’) putchar(c);
(4) ;
c= (5) ;
}
}
[填空题]请补充main函数,该函数的功能是:输入两个正整数m和n,求这两个数的最大公约和最小公倍数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
main ( )
{
int a, b, n, m, t;
clrscr ( );
printf ("/nInput two numbers: /n");
scanf ("%d, %d", &n, &m);
if (n<m)
{
a=m;
b=n;
}
else
{
a=n;
b=m;
}
while( 【1】 )
{
t= 【2】
a=b;
b=t;
}
printf ("greatest con. non divisor:
%d/n", a);
printf ("least common multiple:
%d/n", 【3】 );
}
[填空题]请补充main函数,该函数的功能是:输入两个正整数m和n,求这两个数的最大公约和最小公倍数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
main ( )
int a, b, n, m, t;
clrscr ( );
printf ("/nInput two numbers: /n");
scanf ("%d, %d", &n, &m);
if (n<m)
a=m;
b=n;
else
a=n;
b=m;
while( 【1】 )
t= 【2】
a=b;
b=t;
printf ("greatest con. non divisor:
%d/n", a);
printf ("least common multiple:
%d/n", 【3】 );
[简答题][说明]
下面的程序利用递归算法计算x和y的最大公约数。
[函数2.1]
main ( )
int x,y,k,t;
scanf(" % d% d" , &x, &y);
if(x>y) t=x;x=y; y=t;
(1) ;
while(k! =0)
y=x;
(2) ;
k=y%x;
prinff( "% d" ,x);
[函数2.2说明]
函数fun(char *str,char *substr的功能是计算子串sugbstr在串str中出现的次数。
[函数2.2]
fun(ehar * str, char * substr)
int x,y,z;
(3) ;
for(x=0;str[ x] ! = ’/O’;x + + )
for(y=x,z=0;sabstr[z] = =str[y]; (4) ,y+ +)
if( (5) = =’/0’)
num + +;
break;
return(num);
[简答题][说明]
下面的程序利用递归算法计算x和y的最大公约数。
[函数2.1]
main ( )
{ int x,y,k,t;
scanf(" % d% d" , &x, &y);
if(x>y) { t=x;x=y; y=t;}
(1) ;
while(k! =0){
y=x;
(2) ;
k=y%x;
}
prinff( "% d" ,x); }
[函数2.2说明]
函数fun(char *str,char *substr的功能是计算子串sugbstr在串str中出现的次数。
[函数2.2]
fun(ehar * str, char * substr)
{ int x,y,z;
(3) ;
for(x=0;str[ x] ! = ’/O’;x + + )
for(y=x,z=0;sabstr[z] = =str[y]; (4) ,y+ +)
if( (5) = =’/0’) {
num + +;
break;
}
return(num);
}
[填空题]以下程序中,函数fun的功能是计算x2-2x+6,主函数中将调用fun函数计算:
y1=(x+8)2-(x+8)+6
y2=sin2(x)-2sin(x)+6
请填空。
# include<math.h>
double fun(double x)return(x*x-2*x+6);
main( )
double x,y1,y2;
printf("Enter x:");scanf("%1f",&x);
y1=fun(______)
y2=fun(______)
printf("y1=%1f, y2=%1f/n",y1, y2);
[填空题]以下程序中,函数fun的功能是计算x2-2x+6,主函数中将调用fun函数计算:
y1=(x+8)2-2(x+8)+6
y2=sin2(x)-2sin(x)+6
请填空。
ginclude "math.h"
double fun(double x){return(x*x-2*x+6);}
main( )
{double x,y1,y2;
pfintf("Enterx:");scanf("%lf"&x);
y1=fun( [10] );y2=fun( [11] );
pintf("y1=%lf,y2=%lf/n",y1,y2);
}
[填空题]下列程序中,fun( )函数的功能是计算x2-2x+6,主函数中将调用fun( )函数计算。
y1=(x+8)2-2(x+8)+6
y2=sin2(x)-2sin(x)+6
请填空
#include "math.h"
double fun(double x)return(x*x-2*x+6);)
main( )
double x,y1,y2;
printf("enter x:");scanf("%1f",&x);
y1=fun(______);
y2=fun(______);
printf("y1=%1f,y2=%1f/n",y1,y2);
[填空题]
以下程序中,函数fun的功能是计算x2(上标)-2x+6,主函数中将调用fun函数计算:
y1=(x+8)2(上标)-2(x+8)+6
y2=sin2(上标)(x)-2sin(x)+6
请填空。
#include "math.h"
double fun(double x){ return (x*x-2*x+6);}
main( )
{ double x,y1,y2;
printf("Enter x:"); scanf("%1f",&x);
y1=fim(());
y2=run(());
printf("y1=%1f,y2=%1f/n",y1,y2);
}
[填空题]以下程序中,函数fun的功能是计算X的2次方-2x+6,主函数中将调用fun函数计算:
y1=(x+8)的2次方-2(X+8)+6
y2=sin2(x)一2sin(x)+6
请填空。
#include "math.h"
double fun(double X){return(X*x-2*X+6);}
main( )
{double x,yl,y2;
printf("Enter x:");scanf("%If",&x);
y1=fun(【 】);
y2=fun(【 】);
printf("y1=%If,y2=%lf\n",y1,y2);
}
[填空题]以下程序中,函数fun的功能是计算x2(上标)-2x+6,主函数中将调用fun函数计算:
y1=(x+8)2-2(x+8)+6
y2=sin2(x)-2sin(x)+6
请填空。
#include "math.h"
double fun(double x) return (x*x-2*x+6);
main( )
double x,y1,y2;
printf("Enter x:"); scanf("%1f",&x);
y1=fim(______);
y2=run(______);
printf("y1=%1f,y2=%1f/n",y1,y2);
[填空题]下列程序中,fun( )函数的功能是计算x2-2x+6,主函数中将调用fun( )函数计算。
y1=(x+8)2=2(x+8)+6
y2=sin2(x)-2sin(x)+6
请填空:
#include<math.h>
double fun(double x)return(x*x-2*x+6);
main( )
double x, y1, y2;
printf("enter x: "); scanf("%1f", &x);
y1=fun(______);
y2=fun(______);
printf("y1=%1f, y2=%1f/n", y1, y2);
[填空题]以下程序中,函数fun的功能是计算x2-2x+6,主函数中将调用fun函数计算,请填空。
y1=(x+8)2-2(x+8)+6
y2=sin2(x)-2sin(x)+6
#include "math.h"
double fun(double x) return( (8) );
main( )
( double x,y1,y2;
printf("Enter x:"); scanf("%1f",&x);
yl=fun(8+x);
y2=fun( (9) );
printf("y1 =%1f,y2=%1f/n",y1,y2);