|
|
10
10
c = 5, b = c, a = b
14 5 9
if (x < 0) { z = -x; } else if (x > 0) { z = x; }
A:
if (size > 12) {cost = cost * 1.05; flag = 2;};
else { bill = cost * flag};
B:
if (ibex > 14) { sheds = 3}; else { sheds = 2; help = 2 * sheds;}
C:
if (score < 0) { printf("count = %d\n", count)} else {count++}
- #include <stdio.h>
- #include <math.h>
- int main(){
- int count = 1, TF = 1;
- double x, y;
- do {
- x = 10000 * 0.1 * count + 10000;
- y = 10000 * pow((1 + 0.05), count);
- if (x < y){
- TF = 0;
- }
- count++;
- } while (TF);
-
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", count - 1);
- printf("小甲鱼的投资额是:%.2f\n", x);
- printf("黑夜的投资额是:%.2f\n", y);
- return 0;
- }
复制代码- #include <stdio.h>
- #include <math.h>
- int main(){
- double base = 4000000.0;
- int count = 1;
- do {
- base = (base - 500000.0) * (1 + 0.08);
- count++;
- } while (base >= 0);
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", count - 1);
- return 0;
- }
复制代码- #include <stdio.h>
- #include <math.h>
- int main(){
- int count=0, num = 1, i=1;
- double sum=0.0;
- double term;
- do {
- term = (double)1 / num;
- sum += i * term;
- i = -i;
- num += 2;
- } while (fabs(term) >= pow(10, -8));
- printf("Pi的近似值为%.7lf", sum * 4);
- return 0;
- }
复制代码- #include <stdio.h>
- #include <math.h>
- int main(){
- int parent = 2, child1 = 0, child2 = 0;
- int time;
- for (time = 0; time < 24; time++)
- {
- parent += child2;
- child2 = child1;
- child1 = parent / 2;
- }
- printf("两年后可以繁殖出%d对", child1 / 2);
- return 0;
- }
复制代码 |
|