C语言考试题 最好详细一点

C语言考试题 最好详细一点第二十二题
2025-04-07 11:31:36
推荐回答(1个)
回答1:

//21题
#include "stdio.h"

main()
{
float s=0;
float a=1;
float b=2;
int n;
int i;
float temp;

scanf("%d",&n);

for(i=0;i {
s+=b/a;
temp=a;
a=b;
b=temp+a;
}
printf("%f",s);
}
//22题,因为看不清中间符号,就按加号来处理了 
#include "stdio.h"
#include "math.h"

main()
{
double s=1;
double n;
double i;

scanf("%lf",&n);

for(i=1;i<=n;i++)
{
s+= log(i);
}
printf("%lf",sqrt(s));
}