更多"请补充fun( )函数,该函数的功能是求m的阶乘。不要改动主函数mai"的相关试题:
[填空题]请补充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));
[填空题]请补充函数fun( ),函数fun( )的功能是求7的阶乘。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
long fun(int n)
if( 【1】 )
return(n*fun( 【2】 );
else if( 【3】 )
return 1;
main( )
int k=7;
printf("%d!=%ld/n", k, fun(k));
[填空题]请补充main( )函数,该函数的功能是:输出一个4×4的矩阵,要求必须使用行指针表示输出变量。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
static int arr[4][4]=(9,8,7,6),
6,5,4,3,
3,2,1,0,
2,4,6,8;
int(*p)[4],j,i;
p= (1) ;
system("CLS");
for(i=0;i<4;i++)
printf("/n/n");
for(j=0;j<4;j++)
printf("%4d", (2) );
[填空题]请补充main( )函数,该函数的功能是:打印出1~10000中满足个位数字的立方等于其本身的所有数。
本题的结果为:1 64 125 216 729
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i, k;
system("CLS");
for(i=1; i<10000; i++)
k= (1) ;
if( (2) )
printf("%4d", i);
[填空题]请补充main( )函数,该函数的功能是:计算每个学生成绩的平均分,并把结果保存在数组aver中。
例如,当score[N][M]=(83.5,82,86,65,67,80,91.5,84,99,95,90.5,95,86,95,97时,3个学生的平均分为76.7 89.9 92.7。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 3
#define M 5
void main( )
int i,j;
static float score[N][M]=(83.5,82,86,65,67),80,91.5,84,99,95,90.5,95,86,95,97;
float aver[N];
system("CLS");
for(i=0;i<N;i++)
(1) ;
for(i=0;i<N;i++)
for(j=0;j<M;j++)
(2) ;
aver[i]/=M;
for(i=0;i<N;i++)
printf("/nstudent%dktaverage=%5.1f",i+1,aver[i]);
[填空题]请补充main( )函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i=0;
char *arr[3]="hoih", "yufui", "xgf";
char **p;
char str[8];
system("CLS");
(1) ;
for(i=0; i<3; i++)
str[i]= *p[i];
while(* p[i])
if (str[i]<*p[i])
str[i]=*p[i];
(2) ;
(3) ;
printf("new string/n");
puts(str);
[填空题]下列程序中,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);
[填空题]请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main( )
{
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d", &n);
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
{
if(【1】)
bb[i] [j]=l;
else
【2】;
}
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
{
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
}
}
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。
程序运行后的结果为42.40。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
{
int i, j, n=0,flag;
float aver=0;
clrscr( );
for(j=2;j<100;i++)
{
flag=1;
for(i=2;i<j;i++)
if( 【1】 )
{
flag=0;
break;
}
if( 【2】 )
{
n++;
aver+=j;
}
}
printf("/n/n average=%4.2f", 【3】 );
}