answer
1
0.10个A
1.0个B
2.?
3.?
4.
1
去
#include <stdio.h>
#include <math.h>
void exercise0();
void exercise1();
void exercise2();
void exercise3();
int main()
{
exercise0();
exercise1();
exercise2();
exercise3();
return 0;
}
void exercise0()
{
int i;
float profit_a, profit_b, principal, rate_a, rate_b;
i = 0;
profit_a = profit_b = principal = 10000;
rate_a = 0.1;
rate_b = 0.05;
while (!(profit_b > profit_a))
{
profit_a += principal * rate_a;
profit_b += profit_b * rate_b;
i++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n", i);
printf("小甲鱼的投资额是:%.2f\n", profit_a);
printf("黑夜的投资额是:%.2f\n", profit_b);
}
void exercise1()
{
int year = 0, expense = 50, principal = 400;
double rate = 0.08;
while (principal > 0)
{
principal -= expense;
principal += principal * rate;
year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", year);
}
void exercise2()
{
int mark, base;
double pi, item;
mark = base = 1;
pi = 0;
do
{
item = mark / (double)base;
pi += item;
mark = -mark;
base += 2;
} while (fabs(item) > 1e-8);
printf("pi = %.7lf\n", 4 * pi);
}
int bunny(int i)
{
if (i < 3)
return 2;
return bunny(i - 1) + bunny(i - 2);
}
void exercise3()
{
printf("%ld\n", bunny(24));
}
0. 100
1. 10
2.
3. ++c + ++b
4. x < 0 ? z = -x : z = x;
5.A.if(size > 12) cost *= 1.05;else bill = cost * flag
B. if(ibex > 14) sheds = 3; else: {sheds - 3; help = 2 * sheds;}
C. do{scanf("%d",&score); count++}while(score < 0);printf("count=%d\n",count)
。
2333
1
T.T
{:9_230:}
答案
1
qweqweqweqweqwe
{:10_333:}
16
0. 100次
1. 11次
2. a
3. a = 14, b = 3, c = 9
4. z = x > 0 ? x:(-x)
P16:拾遗
3.
#include <stdio.h>
#include <math.h>
int main()
{
int n;//months
int pair;//the number of rabits
int i;
int n1;
int n2;
printf("请输入繁殖月数:");
scanf_s("%d", &n);
if (n <= 2)
{
pair = 1;
n1 = 1;
n2 = 1;
}
n1 = 1;
n2 = 1;
for (i = 3; i <= n; i++)
{
pair = n1 + n2;
n1 = n2;
n2 = pair;
}
printf("%d月后,兔子的总对数为:%d\n", n, pair);
return 0;
}