|
发表于 2018-6-20 02:51:25
|
显示全部楼层
本帖最后由 Seerz 于 2018-6-20 10:31 编辑
0. 10个
1. 0个
2. a,b,c
3. a=14, b=5,c=9
4.
5.
A.
- if (size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.
- if (ibex > 14)
- {
- sheds = 3;
- }
- sheds = 2;
- help = 2 * sheds;
复制代码
C.
- while(1)
- {
- readin: scanf("%d", &score);
- if (score < 0)
- {
- break;
- }
- count++;
- }
- printf("count = %d\n", count);
-
复制代码
动动手
0.- #include <stdio.h>
- /*
- A,B 手上各有100000元,A固定年利10%投资,B复利5%投资,多久B超过A?
- */
- int main(int argc, char const *argv[])
- {
- float planA=100000,planB=100000;
- int n=0;
- while(planA>=planB)
- {
- planB *= 1.05;
- planA = planA + 100000 * 0.1;
- n++;
- }
- printf("第%d年,B投资获利%.2f元,超过A投资获利%.2f元\n", n, planB, planA);
- return 0;
- }
复制代码
1.- #include <stdio.h>
- /*
- 400万元,每年拿走50,剩下做8%定期理财,多久财产归零。
- */
- int main(int argc, char const *argv[])
- {
- float property = 400;
- int n=0;
- while (property >= 0)
- {
- property -= 50;
- property *= 1.08;
- n++;
- }
- printf("第%d年,财产归零\n", n);
- return 0;
- }
复制代码
2.- #include <stdio.h>
- #include <math.h>
- /*
- 已知公式 pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 ...
- 求pi
- 精确到小数位7
- */
- int main(int argc, char const *argv[])
- {
- double result = 0, pi, denominator = 1;
- while(denominator < 100000000)
- {
- result = - result + (1/denominator);
- denominator += 2;
- }
- pi = fabs(4 * result);
- printf("圆周率为%.7f\n", pi);
- return 0;
- }
复制代码
3.- #include <stdio.h>
- #include <math.h>
- /*
- 一对兔子,每月可繁殖2一对兔子,小兔子两个月后有繁殖能力,若都健康2年,将繁殖多少对兔子。
- */
- int main(int argc, char const *argv[])
- {
- int n = 3, sum = 0, a=1,b=2;
- for (n; n<= 24; n++)
- {
- sum = a + b;
- a = b;
- b = sum;
-
- }
- printf("2年后一共%d\n对兔子", sum);
- return 0;
- }
复制代码 |
|