c语言练习题,代码无法正常运行

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int func1 (int n)
{
if(n==0||n==1)
{
return 1;
}
else
{
return n*func1(n-1);
}
}
double func2(double x)
{
int n=0;
double s;
while(n<=5){
s = pow((-x),n)/func1(n);
n++;
return (s+func2(n));
}
}
int main ()
{
double s,x;
int n;
n=0;
scanf("%d",&x);
s = func2(x);
printf("the rusult is %f",s);
}
这个代码运行无法正常运行

img


img

代码如下:

#include<stdio.h>
#include<math.h> 
int main(){
  int i = 1,x;
  double y=1.0,sum = 0.0;
  scanf("%d",&x);
  while(y>1e-6){
      if(i%2==1){
          sum+=y;
    }else{
         sum-=y;
    }
    y*=(x*1.0/i);
    i++;
  }
  printf("the rusult is:\t%lf",sum);
  return 0;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632