1
谢谢
100 10 8 3 8
0.9个
1.10
2.a,b,c
3.a=8 b=3 c=3
4.x>=0?z=x:z=-x;
#include <stdio.h>
#define MONEY 10000
int main()
{
double a_total = MONEY, b_total = MONEY;
int count = 0;
do
{
a_total += MONEY * 0.1;
b_total += b_total * 0.05;
count++;
} while(a_total >= b_total);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", count);
printf("小甲鱼的投资额是:%.2f\n", a_total);
printf("黑夜的投资额是:%.2f\n", b_total);
return 0;
}
谢谢小甲鱼
准备做考核
{:7_146:}
1
{:10_277:}
1
0.10
1.10
2.a=5
3.c=10;b=5;a=3
4.
#include <stdio.h>
int main()
{
int x,z;
printf("请输入:");
scanf("%d",&x);
if (x>0)
;
else if (x<0)
x=-x;
z=x;
printf("绝对值为:%d\n",z);
return 0;
}
5.if (size > 12)
{
cost = cost * 1.05;//goto a;
flag = 2;
}
bill = cost * flag;
//goto b;
a: //cost = cost * 1.05;
//flag = 2;
b: //bill = cost * flag;
11
hh
dd
0.
10
1.
0
2.
5
3.
a b c
4.
aa
kan
测试题:
0. 10
1. 0
2. a, b, c
3. a=14, b=5, c= 9
4. z = x >= 0 ? x : -x ;
5.
A.if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
B. if (ibex > 14)
{
sheds = 3;
}
else
{
sheds = 2;
}
help = 2 * sheds;
C.scanf("%d", &score);
while (score >= 0)
{
count++;
scanf("%d", &score);
}
printf("count = %d\n", count);
动动手:
0.#include <stdio.h>
#define RATE_F 0.1
#define RATE_D 0.05
#define MONEY 10000
int main()
{
int i;
floatmoney_f = MONEY, money_d = MONEY;
for (i = 0; money_d <= money_f; i++)
{
money_d = money_d * (1 + RATE_D);
money_f = MONEY * (1 + RATE_F * (i + 1));
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n", i);
printf("小甲鱼的投资额是:%.2f\n", money_f);
printf("黑夜的投资额是:%.2f\n", money_d);
return 0;
}
1.#include <stdio.h>
int main()
{
int money = 4000000, i;
float rate = 0.08;
for (i = 0; money > 0; i++)
{
money = (money - 500000) * (1 + rate);
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", i);
return 0;
}
2.#include <stdio.h>
#include <math.h>
int main()
{
int i;
double pi = 0, j = 1;
for (i = 0; j > 1e-8; i++)
{
j = 1.0 / (i * 2.0 + 1);
pi = pi + pow(-1, i) * j;
printf("现在j = %.7f\n", j);
}
pi = pi * 4;
printf("π的近似值为:%.7f\n", pi);
return 0;
}
3.#include <stdio.h>
int main()
{
int month1 = 1, month2 = 2, month3 = 3, i;
int a, b, c;
for (i = 3; i <= 24; i++) //从第三个月开始计算
{
a = month1 , b = month2, c = month3;
month1 = b, month2 = c, month3 = a + c;
}
printf("两年后,兔子数量为:%d\n", month3);
return 0;
}
// 运行结果:两年后,兔子数量为:12664
111