#include<stdio.h>
void fun(float *s,int n)
{
int i,m;
for(s=0,i=1;i<=n;i++)
{
if(i%2==0)m=-1;
else m=1;
s=s+m/(2*i-1);
}
}
int main()
{
int n;
float m;
scanf("%d",&n);
fun(m,n);
printf("s=%d\n",m);
return 0;
}
然后就会出现这样的问题
Compile Error(编译出错) temp.cpp: In function 'int main()':
temp.cpp:17:9: error: cannot convert 'float' to 'float*' for argument '1' to 'void fun(float*, int)'
fun(m,n);
^