回复 3楼 rjsp
#include<stdio.h>
double *Sum(double*p,int n);
int main()
{
int n;
double *p;
printf("输入n: ");
scanf("%d",&n);
printf("结果=%0.2lf",p);
return 0;
}
double *Sum(double*p,int n)
{
double s=0.0;
double i;
if(n%2==0)
{
for(i=2.0;i<=n;i=i+2.0)
s=s+(1.0/i);
*p=s;
}
else
{
for(i=1;i<=n;i=i+2)
s=s+(1.0/i);
*p=s;
}
return (p);
}
我的这个运行结果是0;