From 3e8ac7ba4a8f410703aa5a8426f542217adcbf2f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 14 Nov 2025 20:55:42 +0200 Subject: feat(Week07): Add solutions --- Week07/Exercise07.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Week07/Exercise07.cpp (limited to 'Week07/Exercise07.cpp') diff --git a/Week07/Exercise07.cpp b/Week07/Exercise07.cpp new file mode 100644 index 0000000..6bb2a8c --- /dev/null +++ b/Week07/Exercise07.cpp @@ -0,0 +1,25 @@ +#include + +// Припомняме, че "unsigned" е същото като "unsigned int" +unsigned sumElems(int* arr, unsigned size) { + int sum = 0; + for (unsigned int i = 0; i < size; i++) + sum += arr[i]; + return sum; +} + +int main() { + const unsigned int SIZE = 11; + int input[SIZE]; + for (unsigned int i = 0; i < SIZE; i++) + std::cin >> input[i]; + + for (unsigned int i = 0; i <= SIZE - 3; i++) { + if (sumElems(input + i, 3) == 0) { + std::cout << input[i] << ' ' << input[i + 1] << ' ' << input[i + 2] << std::endl; + return 0; + } + } + + return 0; +} -- cgit v1.3.1-23-gd82d