diff options
feat(Week07): Add solutions
1 files changed, 23 insertions, 0 deletions
| -rw-r--r-- | Week07/Exercise14.cpp | 23 |
diff --git a/Week07/Exercise14.cpp b/Week07/Exercise14.cpp new file mode 100644 index 0000000..9556520 --- /dev/null +++ b/Week07/Exercise14.cpp @@ -0,0 +1,23 @@ +#include <iostream> + +const unsigned int SIZE_INPUT = 10, SIZE_OUTPUT = 5; + +void subtractions(const double input[SIZE_INPUT], double output[SIZE_OUTPUT]) { + for (unsigned int i = 0; i < SIZE_OUTPUT; i++) + output[i] = input[i * 2 + 1] - input[i * 2]; +} + +int main() { + double in[SIZE_INPUT], out[SIZE_OUTPUT]; + + for (unsigned int i = 0; i < SIZE_INPUT; i++) + std::cin >> in[i]; + + subtractions(in, out); + + for (unsigned int i = 0; i < SIZE_OUTPUT; i++) + std::cout << out[i] << ' '; + std::cout << std::endl; + + return 0; +} |
