diff options
feat(Week04): Add exercises and solutions
1 files changed, 26 insertions, 0 deletions
| -rw-r--r-- | Week04/Exercise06.cpp | 26 |
diff --git a/Week04/Exercise06.cpp b/Week04/Exercise06.cpp new file mode 100644 index 0000000..81dc3b4 --- /dev/null +++ b/Week04/Exercise06.cpp @@ -0,0 +1,26 @@ +#include <iostream> + +int main() { + const float PI = 3.14159; + + unsigned short shape; + std::cin >> shape; + + if (shape == 1) { + float r; + std::cin >> r; + std::cout << (2.0 * PI * r); + } + else if (shape == 2) { + float a, b; + std::cin >> a >> b; + std::cout << (2.0 * a + 2.0 * b); + } + else if (shape == 3) { + float a, b, c; + std::cin >> a >> b >> c; + std::cout << (a + b + c); + } + + return 0; +} |
