|
发表于 2020-2-28 13:48:29
|
显示全部楼层
本帖最后由 zm_selina 于 2020-2-28 13:52 编辑
测试题:
0:10个A
1: 0个B
2:a,b,c
3:14, 9, 5
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>
- int main()
- {
- int year = 0;
- float xijiayu = 10000, heiye = 10000;
- float i = 0.1, j = 0.05;
-
- while(1)
- {
- xijiayu += 10000 * i;
-
- heiye *= (1 + j);
-
- year++;
-
- if(heiye > xijiayu)
- {
- break;
- }
- }
-
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
- printf("小甲鱼的投资额是:%.2f\n", xijiayu);
- printf("黑夜的投资额是:%.2f\n", heiye);
-
- return 0;
- }
复制代码
1:
- #include <stdio.h>
- int main()
- {
- int year = 0;
- float money = 4000000, spending = 500000;
- float i = 0.08;
-
- while(money>0)
- {
- money = (money-spending)* (1+i);
-
- year++;
-
- }
-
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...!\n", year);
-
- return 0;
- }
复制代码
2:
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double pi = 0;
-
- double i = 1, flag = 1;
-
- while(1)
- {
- pi = pi + (1/i*flag);
-
- i = i + 2;
-
- flag = - flag;
-
- if(1/i < pow(10,-8))
- {
- break;
- }
-
- }
-
- printf("%.7f", pi*4);
-
- return 0;
- }
复制代码
3:
- #include <stdio.h>
- int main()
- {
- int a = 0, b = 1, c = 0, i;
-
- for(i=1; i<=24; i++)
- {
- a = b;
- b = c;
- c = a + b;
-
- printf("%d ", c);
- }
-
-
- return 0;
- }
复制代码 |
|