aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-05-30 10:49:09 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2019-05-30 10:49:09 +0200
commit4003baa8d9b87c0cb7f07d32d6d3a7d0e67fbf98 (patch)
tree2cce9c873e21362d9c594211bc35d202904c24f2 /c
parentae6586851bc078967c311558b1871eaab10bdad3 (diff)
downloadAceptaElReto-4003baa8d9b87c0cb7f07d32d6d3a7d0e67fbf98.tar.gz
AceptaElReto-4003baa8d9b87c0cb7f07d32d6d3a7d0e67fbf98.zip
Resuelto 513 en c++: Empleado del año.
Diffstat (limited to 'c')
-rw-r--r--c/513_empleadoDelAño.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/c/513_empleadoDelAño.cpp b/c/513_empleadoDelAño.cpp
new file mode 100644
index 0000000..6df3fb8
--- /dev/null
+++ b/c/513_empleadoDelAño.cpp
@@ -0,0 +1,20 @@
+#include <iostream>
+
+using namespace std;
+
+// mean: Ex / n = m; a/n + b/n + x/n = m; (a+b)/n = m - x/n; x = -n((a+b)/n-m)
+int main() {
+ int days, day, total, mean;
+ while (cin >> days) {
+ total = 0;
+ for (int n = 1; n <= days; n++) {
+ cin >> mean;
+ day = n*mean-total;
+ total += day;
+ if (n != days)
+ cout << day << " ";
+ else
+ cout << day << endl;
+ }
+ }
+}