哪位大哥大姐帮忙做一下下面的c语言题目啊.. 只有三题。 谢谢 啊....

2024-12-13 20:09:01
推荐回答(4个)
回答1:

1------------------
#include

double fun (int n)
{
double f1 = 1.0, f2 = 1.0, f = 2.0, tmp;
double sum = 0.0;
int i;

for (i = 0; i < n; ++i)
{
sum += f2/f;
tmp = f1;
f1 = f2;
f = f + f2;
f2 = f1+tmp;
}
return sum;
}

int main(void)
{
int n;
printf("Enter number:");
scanf("%d", &n);
printf("%f\n", fun(n));
return 0;
}
2-----------------------------------
#include
#include

void invert(char str1[])
{
int a, b;
char c;
for (a=0, b=strlen(str1);a {
c=str1[a];
str1[a]=str1[b-1];
str1[b-1]=c;
}
printf("%s\n", str1);
}
int main(void)
{
char str[128];

printf("INPUT:");
scanf("%s", str);
invert(str);
printf("%s\n", str);
return 0;
}
3----------------------------
#include

int fun(int n)
{
int i = n;
int sum = 1;

for (; i > 0; --i)
sum*=i;
return sum;
}
int main(void)
{
int i;
double sum = 1.0;

for (i = 2; i <= 10; ++i)
{
if (i%2==0)
sum += (-1)*(1.0/fun(i));
else
sum += (1.0/fun(i));
}
printf("%f\n", sum);
return 0;
}

回答2:

20分也没人做的

回答3:

没分没人做的。

回答4:

1