填空题
[说明]
编写一个函数,输入为偶数时,调用函数求1/2+?/+…+1/n,当输入n为奇数时,调用函数1/1+1/3+…+1/n (利用指针函数)。
[函数]
#include "stdio. h",
main()
{
float peven (),podd (),dcall ();
float sum;
int n;
while{{U}} (1) {{/U}}
{
scanf("%d",&n);
if (n>1)
break;
}
if(n%2==0)
{
printf("Even="):
(1);
}
else
{
pfinff("Odd=");
{{U}} (2) {{/U}};
}
printf("%f",sum);
}
float peven (int n)
{
float s;
int i
s=1;
for(i=2;i<=n;i+=2)
{{U}} (3) {{/U}};
return (s);
}
float podd (n)
int n;
{
float s;
int i;
s=0;
for(i=1 i<=n;i+=2)
{{U}} (4) {{/U}};
return (s);
}
float dcall(fp,n)
float (*fp) ();
int n;
{
float s;
{{U}}(5) {{/U}};
returu (s);
}
【正确答案】
1、(1)array+10 (2)array+1 (3)*p>*max (4)k=*max (5)*p=array[0]
【答案解析】