Переглянути джерело

[C] Adding solution for problem 0001

Vinicius Teshima 1 рік тому
батько
коміт
ef0c042e52
4 змінених файлів з 105 додано та 0 видалено
  1. 5 0
      c/.gitignore
  2. 24 0
      c/0001.c
  3. 57 0
      c/Makefile
  4. 19 0
      c/Project.ede

+ 5 - 0
c/.gitignore

@@ -0,0 +1,5 @@
+.deps
+*.o
+
+# Executables
+0001

+ 24 - 0
c/0001.c

@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdint.h>
+
+int
+main(int argc, const char **argv)
+{
+	uint64_t sum = 0;
+	uint64_t i = 0;
+	uint64_t mod3 = 0, mod5 = 0;
+	uint64_t upper_limit = 1000;
+
+	for ( i = 0; i < upper_limit; ++i ) {
+		mod3 = i % 3;
+		mod5 = i % 5;
+		sum += ( mod3 == 0 && mod5 != 0 ) * i
+			+ ( mod5 == 0 && mod3 != 0 ) * i
+			+ ( mod5 == 0 && mod3 == 0 ) * i;
+	}
+
+	printf("Result = %ld!\n", sum);
+	(void) argc; (void) argv;
+	return 0;
+}
+

+ 57 - 0
c/Makefile

@@ -0,0 +1,57 @@
+# Automatically Generated Makefile by EDE.
+# For use with: make
+# Relative File Name: Makefile
+#
+# DO NOT MODIFY THIS FILE OR YOUR CHANGES MAY BE LOST.
+# EDE is the Emacs Development Environment.
+# https://cedet.sourceforge.net/ede.shtml
+#
+CFLAGS=-std=c89 -m64 -Og -ggdb -pedantic -Wall -Wextra -Wshadow -Wcast-align -Wunused -Wconversion -Wmisleading-indentation -Wdouble-promotion -Wformat=2 -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Werror $(shell pkg-config --libs ${LIBS}) -I src/external -fsanitize=address
+
+top=
+ede_FILES=Project.ede Makefile
+
+0001_SOURCES=0001.c
+0001_OBJ= 0001.o
+CC=gcc
+C_COMPILE=$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+C_DEPENDENCIES=-Wp,-MD,.deps/$(*F).P
+C_LINK=$(CC) $(CFLAGS) $(LDFLAGS) -L.
+VERSION=1.0
+DISTDIR=$(top)ProjectEuler_C-$(VERSION)
+top_builddir = 
+
+DEP_FILES=.deps/0001.P
+
+all: 0001
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+-include $(DEP_FILES)
+
+%.o: %.c
+	@echo '$(C_COMPILE) -c $<'; \
+	$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<
+
+0001: $(0001_OBJ)
+	$(C_LINK) -o $@ $^ $(LDDEPS)
+
+tags: 
+
+
+clean:
+	rm -f *.mod *.o *.obj .deps/*.P .lo
+
+.PHONY: dist
+
+dist:
+	mkdir $(DISTDIR)
+	cp $(0001_SOURCES) $(ede_FILES) $(DISTDIR)
+
+Makefile: Project.ede
+	@echo Makefile is out of date!  It needs to be regenerated by EDE.
+	@echo If you have not modified Project.ede, you can use ‘touch’ to update the Makefile time stamp.
+	@false
+
+
+
+# End of Makefile

+ 19 - 0
c/Project.ede

@@ -0,0 +1,19 @@
+;; Object ProjectEuler_C
+;; EDE Project Files are auto generated: Do Not Edit
+(ede-proj-project "ProjectEuler_C"
+  :file "Project.ede"
+  :name "ProjectEuler_C"
+  :targets
+  (list
+    (ede-proj-target-makefile-program "0001"
+      :object-name "0001"
+      :name "0001"
+      :path ""
+      :source '("0001.c")
+      :configuration-variables '("debug" ("CFLAGS" . "-g") ("LDFLAGS" . "-g"))))
+  :configurations '("debug" "release")
+  :object-name "ProjectEuler_C"
+  :makefile-type Makefile
+  :variables '(("CFLAGS" . "-std=c89 -m64 -Og -ggdb -pedantic -Wall -Wextra -Wshadow -Wcast-align -Wunused -Wconversion -Wmisleading-indentation -Wdouble-promotion -Wformat=2 -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Werror $(shell pkg-config --libs ${LIBS}) -I src/external -fsanitize=address"))
+  :configuration-variables nil
+  :metasubproject t)