小细胞
发表于 2020-12-7 12:44:58
1
lzt456
发表于 2020-12-7 14:42:01
1
Pseud
发表于 2020-12-7 15:26:05
0
18204769992
发表于 2020-12-7 17:00:26
#include<stdio.h>
#include<math.h>
int main()
{double j,i=0,pi;
int n;
for(n=1;n>0;n++)
{if(n%2!=0)
{
i=i+1.0/(2*n-1);
}
if(n%2==0)
{i=i-1.0/(2*n-1);
}
if(fabs(i)<1e-8)
{pi=i*4.0;
break;
}
}
printf("pi的值为%.7f",pi);
return 0;
}
YYQZ
发表于 2020-12-7 21:25:55
1
残月昭雪
发表于 2020-12-7 23:42:30
想了好久,终于写出来一个了哈哈哈,但是貌似有点复杂
Dadong丶
发表于 2020-12-8 09:58:25
#include<stdio.h>
#define xjy_ll 1.1
#define hy_ll 1.05
int main()
{
float xjy, hy;
xjy = 10000; hy = 10000;
int i = 0;
xjy = xjy * xjy_ll;
while (hy < xjy)
{
hy = hy * hy_ll;
i++;
}
printf("%d,年后,黑夜超过小甲鱼!\n",i);
printf("小甲鱼的投资是%f\n", xjy);
printf("黑夜的投资是%f\n", hy);
}
Dadong丶
发表于 2020-12-8 10:04:17
#include<stdio.h>
#define hl 1.08
int main()
{
double bj = 4000000;
int i = 0;
while (bj > 500000 || bj < 0)
{
bj = bj * hl - 500000;
i++;
}
printf("%d年后,败光所有家产",i);
return 0;
}
Dadong丶
发表于 2020-12-8 10:54:31
#include<stdio.h>
#include<math.h>
int main()
{
double n;
double N = 0.0;
double i, j;
n = 1.0;
i = 1.0;
j = 1.0;
while (fabs(n) >= 1e-8)
{
N = N + n;
i = i + 2;
j = -j;
n = j / i;
//N = N + n; 放在这里就出错了。好在搞懂了。
}
N = 4 * N;
printf("%.7f\n", N);
return 0;
}
Iceorigin
发表于 2020-12-8 16:58:05
感谢无私奉献
在哪里呐/
发表于 2020-12-8 21:35:09
答案
ImFallen
发表于 2020-12-8 23:08:02
1
1990160770
发表于 2020-12-9 15:37:41
嘿嘿嘿
xg-sco
发表于 2020-12-9 15:47:48
0.
# include <stdio.h>
# include <math.h>
# define money 10000
int main ()
{
double fish_money = money, night_money = money;
double rate1 = 0.1, rate2 = 0.05;
int year = 1;
do
{
fish_money = money * rate1 * year + money;
night_money = money * pow((1 + rate2), year);
year++;
continue;
}
while(fish_money > night_money);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", year - 1);
printf("小甲鱼的投资额是:%.2lf\n", fish_money);
printf("黑夜的投资额是:%.2lf\n", night_money);
return 0;
}
1.
# include <stdio.h>
int main ()
{
int year = 0;
double money = 4000000;
double rate = 0.08;
while (money >= 0)
{
money = money - 500000;
money = money * (1 + rate);
year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n", year);
return 0;
}
2.
# include <stdio.h>
# include <math.h>
int main ()
{
double num = 1, pi = 0;
int i = -1;
while (fabs(i / num) > 1e-8)
{
i = -i;
pi = i / num + pi;
num += 2;
}
pi = pi * 4;
printf("pi = %.7f", pi);
return 0;
}
3.
# include <stdio.h>
int main ()
{
int month;
int f1 = 1, f2 = 1, f3;
for (month = 1; month <= 24; month++)
{
f3 = f1 + f2;
f1 = f2;
f2 = f3;
}
printf("%d", f3);
return 0;
}
GuoJimmy
发表于 2020-12-9 17:09:26
1
“或许”
发表于 2020-12-9 17:23:22
{:10_323:}
一个瓜皮路人
发表于 2020-12-9 20:07:58
ge t
牧影人
发表于 2020-12-11 23:32:27
1
暮色丶月夜
发表于 2020-12-12 00:25:17
q
qq2760958935
发表于 2020-12-12 12:54:15
2333