炤靈
发表于 2022-3-27 21:11:59
gui yi de ti
爱我吧新手
发表于 2022-3-28 15:21:53
1
张郝源
发表于 2022-3-28 15:24:20
。
ZHONG.Y.H
发表于 2022-3-29 15:43:15
本帖最后由 ZHONG.Y.H 于 2022-3-29 15:47 编辑
测试题
0:10次
1:0次
2:c, b, a
3:首先 b = 3(因为赋值运算符的优先级比逗号运算符高);c = b++ + 5,c = 8(因为 b++ 是先使用变量 b 的值,再将自身加一);a 最后的值是 ++c + ++b,此时 c = 8,b = 4,则 a = 9 + 5,最后 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"
int main()
{
double fish = 10000;
double night = 10000;
int i = 1;
do
{
fish = fish + 10000 * 0.1;
night = night * (1 + 0.05);
i++;
}while(fish > night);
printf("%d\n", i);
return 0;
}
1:
#include "stdio.h"
int main()
{
double money = 4000000;
int i = 1;
while(money > 0)
{
money = money * (1 + 0.08);
money = money - 500000;
i++;
}
printf("%d", i);
return 0;
}
2:
#include <stdio.h>
#include <math.h>
int main()
{
int sign = 1; // 表示符号
double pi = 0.0, n = 1, term = 1.0; // n表示分母,term表示当前项的值
while (fabs(term) >= 1e-8) // 1e-8表示10^(-8)
{
pi = pi + term;
n = n + 2;
sign = -sign;
term = sign / n;
}
pi = pi * 4;
printf("pi = %10.7f\n", pi);
return 0;
}
3:#include <stdio.h>
int main()
{
long a = 1, b = 1, c, i;
for (i = 3; i <= 24; i++)
{
c = a + b;
a = b;
b = c;
}
printf("两年后,总共有%ld只兔子!\n", c);
return 0;
}
罗达峰
发表于 2022-3-29 17:22:09
。
Yolo-
发表于 2022-3-30 09:09:58
0.100
1.11
2.a
3.14 59
Crazy.柟
发表于 2022-3-30 10:19:33
1
邹小小
发表于 2022-3-30 10:55:33
1
YayoiOvO
发表于 2022-3-30 15:01:14
1
kazuya8375
发表于 2022-3-30 20:21:16
-966666666
hooinkyoma
发表于 2022-3-30 20:49:09
S1E16:拾遗 | 课后测试题及答案 [修改]
控心少年不会C
发表于 2022-3-31 08:57:20
l、
摸鱼人
发表于 2022-3-31 12:11:09
1
937193963
发表于 2022-3-31 14:43:19
loat jSum = 10000;
float hSum = 10000;
int i = 0;
while (hSum <= jSum){
i++;
jSum += 10000 * 0.1;
hSum *=(1 + 0.05);
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",i);
printf("小甲鱼的投资额是:%0.2f\n",jSum);
printf("黑夜的投资额是:%0.2f\n",hSum);
int i = 0;
float allMoney = 400;
while (allMoney >= 50){
i++;
allMoney += allMoney * 0.08;
allMoney -= 50;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗。。。。。。",i);
szkyyds
发表于 2022-3-31 21:36:49
jiayou
elise777
发表于 2022-3-31 21:49:47
1
tianxiadi99
发表于 2022-4-1 18:18:18
看看答案
HerrLiu
发表于 2022-4-1 23:04:38
QAQ
Benco
发表于 2022-4-2 22:36:02
交作业
不要偷懒呐
发表于 2022-4-3 18:07:29
第九天