about summary refs log tree commit diff
path: root/others/easy20160714/28.c
diff options
context:
space:
mode:
Diffstat (limited to 'others/easy20160714/28.c')
-rw-r--r--others/easy20160714/28.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/others/easy20160714/28.c b/others/easy20160714/28.c
new file mode 100644
index 0000000..aef9c7a
--- /dev/null
+++ b/others/easy20160714/28.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+	FILE *f = fopen("INP.TXT", "r");
+	int m, n, *a, i, l;
+
+	fscanf(f, "%d %d %d", &m, &n, &i);
+	n *= m;
+	a = malloc(n * sizeof(int));
+
+	for (i = 0; i < n; i++)
+		fscanf(f, "%d", a + i);
+
+	fclose(f);
+
+	l = m = *a;
+
+	for (i = 1; i < n; i++)
+		if (a[i] > m)
+			m = a[i];
+
+	for (i = 1; i < n; i++)
+		if (a[i] < l)
+			l = a[i];
+
+	f = fopen("OUT.TXT", "w");
+	fprintf(f, "%d\n", m - l);
+	fclose(f);
+
+	return 0;
+}