commit b68564447469241913ae49d553acd5f7b7d2bc34
parent 64c58125ce8e1850324835f67fa3eee125a48318
Author: mjkloeckner <martinjkloeckner@gmail.com>
Date: Fri, 15 Mar 2024 13:26:24 -0300
Bulk add ej 13, 14, 15 solutions
Diffstat:
3 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/solutions/ej13.cpp b/solutions/ej13.cpp
@@ -0,0 +1,12 @@
+#include <iostream>
+
+int main (void) {
+ unsigned long first_digit;
+
+ std::cin >> first_digit;
+
+ for (size_t i = 0; i < 20; ++i)
+ std::cout << first_digit + i << std::endl;
+
+ return 0;
+}
diff --git a/solutions/ej14.cpp b/solutions/ej14.cpp
@@ -0,0 +1,22 @@
+#include <iostream>
+
+int main (void) {
+ int fact;
+ unsigned long res;
+
+ std::cin >> fact;
+
+ if(fact < 0) {
+ std::cerr << "Math ERROR" << std::endl;
+ return 1;
+ }
+
+ res = 1;
+ for (size_t i = 1; i <= (long unsigned int)fact; i++) {
+ res *= i;
+ }
+
+ std::cout << fact << "! = " << res << std::endl;
+
+ return 0;
+}
diff --git a/solutions/ej15.cpp b/solutions/ej15.cpp
@@ -0,0 +1,15 @@
+#include <iostream>
+
+int main (void) {
+ long input, res;
+
+ res = 0;
+ do {
+ std::cin >> input;
+ std::cout << "\033[1A\033[0K"; // Borra el numero ingresado
+ std::cout << input << " " << input + res << std::endl;
+ res += input;
+ } while (input != 0);
+
+ return 0;
+}