|
发表于 2019-1-2 13:14:20
|
显示全部楼层
0 9个或者0个,在第一层循环中循环条件是j!=10,但是没有对j初始化,如果碰巧j就是10,那就是0次,否则进入第二层循环,循环十次并且循环结束j=10.
1 0个
2 c b a
3 a14 b5 c9
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:
while(1)
{
scanf("%d", &score);
if(score < 0)
{
printf("count = %d\n", count);
break;
}
count++;
}
- #include <stdio.h>
- #include <stdio.h>
- int main()
- {
- double money = 1000, moneyJ, moneyH;
- int year = 1;
- float p1 = 10.0 / 100, p2 = 1 + 5.0 / 100;
- for (year; ; year++)
- {
- moneyJ = money + money * p1 * year;
- moneyH = money * pow(p2, year);
- if(moneyJ >= moneyH)
- {
- continue;
- }
- break;
- }
-
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
- printf("小甲鱼的投资额是:%.2f\n", moneyJ);
- printf("黑夜的投资额是:%.2f\n", moneyH);
- return 0;
- }
复制代码- #include <stdio.h>
- int main()
- {
- double money = 4000000, cost = 500000, p = 8.0 / 100;
- int year = 0;
- while(money > 0)
- {
- money -= cost;
- money *= (1 + p);
- year++;
-
- }
-
- printf("%d年后,小甲鱼败光了所有的家产,再次变得一贫如洗......\n", year);
- return 0;
- }
复制代码- #include <stdio.h>
- #include <stdio.h>
- int main()
- {
- double pi = 0.0, i;
- int n = 1;
- do
- {
- i = pow (-1, (n-1)) / (2 * n - 1);
- pi = pi + i * 4;
- n++;
- } while (fabs(i) >= pow(10, -8));
- printf("Pi精确到小数点后七位的近似值是:%.7lf\n", pi);
- }
复制代码 |
|