From dba0515e4ff0414e15efa22c7ab86b98ad924f51 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Sun, 21 Jul 2024 09:57:19 +0800 Subject: [PATCH] fix(exercise): 20 Signed-off-by: YdrMaster --- exercises/20_class_template/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/20_class_template/main.cpp b/exercises/20_class_template/main.cpp index fafc1b19..d1dc449d 100644 --- a/exercises/20_class_template/main.cpp +++ b/exercises/20_class_template/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char **argv) { auto t0 = Tensor4D(shape, data); auto t1 = Tensor4D(shape, data); t0 += t1; - for (unsigned int i = 0; i < sizeof(data) / sizeof(int); i++) { + for (auto i = 0u; i < sizeof(data) / sizeof(int); ++i) { ASSERT(t0.data[i] == data[i] * 2, "Tensor doubled by plus its self."); } } @@ -80,7 +80,7 @@ int main(int argc, char **argv) { auto t0 = Tensor4D(s0, d0); auto t1 = Tensor4D(s1, d1); t0 += t1; - for (unsigned int i = 0; i < sizeof(d0) / sizeof(int); i++) { + for (auto i = 0u; i < sizeof(d0) / sizeof(int); ++i) { ASSERT(t0.data[i] == 7.f, "Every element of t0 should be 7 after adding t1 to it."); } } @@ -102,8 +102,8 @@ int main(int argc, char **argv) { auto t0 = Tensor4D(s0, d0); auto t1 = Tensor4D(s1, d1); t0 += t1; - for (unsigned int i = 0; i < sizeof(d0) / sizeof(int); i++) { - ASSERT(t0.data[i] == t0.data[i] + 1, "Every element of t0 should be incremented by 1 after adding t1 to it."); + for (auto i = 0u; i < sizeof(d0) / sizeof(int); ++i) { + ASSERT(t0.data[i] == d0[i] + 1, "Every element of t0 should be incremented by 1 after adding t1 to it."); } } }