Browse Source

Initial commit

Dmitry Yu Okunev 3 years ago
commit
f034c8f518
3 changed files with 28 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 4 0
      1bitarray/Makefile
  3. 23 0
      1bitarray/main.c

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+*/run

+ 4 - 0
1bitarray/Makefile

@@ -0,0 +1,4 @@
+all:
+	gcc main.c -o run
+clean:
+	rm -f run

+ 23 - 0
1bitarray/main.c

@@ -0,0 +1,23 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#define SIZE 26
+
+int main() {
+	uint8_t a[SIZE];
+
+	memset(a, 1, SIZE);
+
+	uint32_t result;
+
+	result = 0;
+	for (int i = 0; i < SIZE; i++) {
+		result += a[i] * (1 << i);
+	}
+
+	printf("%u (0x%x)\n", result, result);
+
+	return 0;
+}
+