更多"编写函数fun( ),函数的功能是:根据以下公式计算s,计算结果作为函"的相关试题:
[简答题]编写函数fun( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)
例如:若n的值为11时,函数的值为1.833333。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
float fun(int n)
{
}
main( )
{
int n;
float s;
clrscr( );
printf("/nPlease enter N: ");
scanf("%d",&n);
s=fun(n);
printf("The result is:%f/n " , s);
}
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)
{
}
main ( )
{
float score[30]=(90.5,72,80,61.5,55},
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);
}
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)
main ( )
float score[30]=(90.5,72,80,61.5,55,
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);
[多项选择]编写函数fun,其功能是:实现B=A+A’,即将矩阵A加上A的转置,存放在矩阵B中。计算结果在main函数中输出。
例如,输入下面的矩阵:
1 2 3
……
4 5 6
……
7 8 9
其转置矩阵为:
1 4 7
……
2 5 8
……
3 6 9
程序输出:
2 6 10
……
6 10 14
……
10 14 18
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void fun(int a[3][3],int b[3][3])
void main( )
(
int a[3][3]=1,2,3,4,5,6,7,8,9,t[3][3];
int i,j;
system("CLS");
fun(a,t);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
print[("%7d",t[i][j]);
printf("/n");
[简答题]编写函数proc( ),函数的功能是:根据以下公式计算s,计算结果作为函数值返回,m通过形参传入。
S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+m)
例如,若n的值为11时,函数的值为1.833333。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
float proc(int m)
void main( )
int m;
float s;
system ("CLS");
printf("/nPlease enter M: ");
scanf("%d", &m);
s=proc(m);
printf("The result is: %f/n", s);
[填空题]函数void fun(float *sn,int n)的功能是:根据以下公式计算s,计算结果通过形参指针 sn传回;n通过形参传入,n的值大于或等于0。请填空。
[*]
void fun(float *sn,int n)
float s=0.0,w,f=-1.0;
int i;
for(i=0;i<=n;i++)
f= * f;
w=f/(2*i+1);
s+=w;
=s;
[填空题]函数viod fun(float * sn,int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请填空。
s=1-1/3+1/5-1/7+…1/(2n+1)
void fun(float * sn,int n)
{ floats=0.0,w,f=-1.0;
int i=0;
for(i=0;i<=n;i+ +)
{ f= 【19】 * f;
w=f/(2i+1);
s+ +=w;
}
【20】 =s;
}
[填空题]函数void fun(noat*sn,int n)的功能是:根据以下公式计算s,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请补全程序。
S=1+1/3+1/5+1/7+…+1/(2n+1)
void fun(float *sn,int n)
float s=0.0,w,f=-1.0;
int i=0;
for(i=0;i<=n;i++)
f= (12) *f;
w=f/(2*i+1);
S+=W:
(13) =s;
[填空题]函数void fun(float*sn,int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请补全程序。
S=1-1/3+1/5-1/7+…+1/(2n+1)
void fun(float*sn,int n)
{ float s=0.0,w,f=-1.0;
int i=0;
for(i=0;i<=n;i++)
{ f= 【14】 *f;
w=f/(2*i+1);
s+=w;
}
【15】 =s;
}
[简答题]m个人的成绩存放在score数组中,请编写函数fun( ),它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。
例如,当score数组中的数据为10,20,30,40,50,60, 70,80,90时,函数返回的人数应该是4,below中的数据应为10,20,30,40。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
int fun(int score[],int m, int below[])
{
}
main( )
{
iht i, n, below[9];
int score[9]={10,20,30,40,50,60,70,
80,90};
clrscr( );
n=fun(score, 9, below);
printf("/nBelow the average score are: ");
for(i=0;i<n;i++)
printf("%d",below[i]);
}
[简答题]规定输入的字符串中只包含字母和*号。编写函数fun,其功能是:删除字符串中所有的*号。编写函数时,不得使用C语言提供的字符串函数。
例如,字符串中的内容为“****A*BC*DEF*G*******”,删除后,字符串中的内容应当是“ABCDEFG”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<conio.h>
#include<sfdio.h>
void fun(char*a)
void main( )
char s[81];
printf("Enter a string:/n");
gets(s);
fun(s);
printf("The string after deleted:/n");
puts(s);