We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2bbc748 commit a2241ccCopy full SHA for a2241cc
exercises/18_function_template/main.cpp
@@ -6,11 +6,15 @@ int plus(int a, int b) {
6
return a + b;
7
}
8
9
-// ---- 不要修改以下代码 ----
10
int main(int argc, char **argv) {
11
- ASSERT(plus(1, 2) == 3, "plus two int");
12
- ASSERT(plus(1u, 2u) == 3u, "plus two unsigned int");
13
- ASSERT(plus(1.f, 2.f) == 3.f, "plus two float");
14
- ASSERT(plus(1.0, 2.0) == 3.0, "plus two double");
+ ASSERT(plus(1, 2) == 3, "Plus two int");
+ ASSERT(plus(1u, 2u) == 3u, "Plus two unsigned int");
+
+ // THINK: 浮点数何时可以判断 ==?何时必须判断差值?
+ ASSERT(plus(1.25f, 2.5f) == 3.75f, "Plus two float");
15
+ ASSERT(plus(1.25, 2.5) == 3.75, "Plus two double");
16
+ // TODO: 修改判断条件使测试通过
17
+ ASSERT(plus(0.1, 0.2) == 0.3, "How to make this pass?");
18
19
return 0;
20
0 commit comments