-
Code bool bool_check(bool bools[3]) { return bools[0] + bools[1] + bools[2] > 1; }
Test Cases bool bool_check(bool []); Test(sample_cases, two_are_true) { cr_assert_eq(bool_check((bool []) {false, true, true}), true); cr_assert_eq(bool_check((bool []) {true, false, true}), true); cr_assert_eq(bool_check((bool []) {true, true, false}), true); } Test(another_case, all_are_true) { cr_assert_eq(bool_check((bool []) {true, true, true}), true); } Test(more_sample_cases, one_is_true) { cr_assert_eq(bool_check((bool []) {true, false, false}), false); cr_assert_eq(bool_check((bool []) {false, true, false}), false); cr_assert_eq(bool_check((bool []) {false, false, true}), false); } Test(last_case, all_are_false) { cr_assert_eq(bool_check((bool []) {false, false, false}), false); }
Output:
-
Code - #include <stdbool.h>
- bool bool_check(bool bools[3]) {
return *bools + *++bools + *++bools > 1;- return bools[0] + bools[1] + bools[2] > 1;
- }
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}