]> web.ist.utl.pt Git - iaed.git/commitdiff
Adding aux.* and Makefile in aula03.
authorAlexandre P Francisco <aplf@ist.utl.pt>
Wed, 12 Mar 2014 14:56:35 +0000 (14:56 +0000)
committerAlexandre P Francisco <aplf@ist.utl.pt>
Wed, 12 Mar 2014 14:56:35 +0000 (14:56 +0000)
aula03/Makefile [new file with mode: 0644]
aula03/aux.c [new file with mode: 0644]
aula03/aux.h [new file with mode: 0644]
aula03/ex1.c
aula03/ex2.c

diff --git a/aula03/Makefile b/aula03/Makefile
new file mode 100644 (file)
index 0000000..69f7462
--- /dev/null
@@ -0,0 +1,18 @@
+CC=gcc
+CFLAGS=-Wall -ansi -pedantic
+
+EXECS=ex1 ex2
+EX1OBJ=ex1.o aux.o
+EX2OBJ=ex2.o aux.o
+
+
+all: ${EXECS}
+
+ex1: ${EX1OBJ} aux.h
+       gcc ${CFLAGS} -o $@ ${EX1OBJ}
+
+ex2: ${EX2OBJ} aux.h
+       gcc ${CFLAGS} -o $@ ${EX2OBJ}
+
+clean:
+       rm -f *.o ${EXECS}
diff --git a/aula03/aux.c b/aula03/aux.c
new file mode 100644 (file)
index 0000000..a894ad5
--- /dev/null
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+void leVector (int v[], int tamanho) {
+  int k;
+  for (k = 0; k < tamanho; k++)
+    scanf("%d", &v[k]);
+}
+
+void escreveVector(int v[], int tamanho) {
+  int k;
+  for (k = 0; k < tamanho; k++)
+    printf("%d\n", v[k]);
+}
+
diff --git a/aula03/aux.h b/aula03/aux.h
new file mode 100644 (file)
index 0000000..f9196df
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef AUX_H
+#define AUX_H
+
+void leVector (int v[], int tamanho);
+void escreveVector(int v[], int tamanho);
+
+#endif /* AUX_H */
index 20879d09fbd6e27bea757426d8f40d07bbade2e3..432708c2f79e70c17b7e25732b4e45c8dc2dcedc 100644 (file)
@@ -1,10 +1,8 @@
 #include <stdio.h>
+#include "aux.h"
 
 #define NUMELEMS 5
 
-void leVector (int v[], int tamanho);
-void escreveVector(int v[], int tamanho);
-
 int main() {
   int v[NUMELEMS];
 
@@ -14,15 +12,3 @@ int main() {
   return 0;
 }
 
-void leVector (int v[], int tamanho) {
-  int k;
-  for (k = 0; k < tamanho; k++)
-    scanf("%d", &v[k]);
-}
-
-void escreveVector(int v[], int tamanho) {
-  int k;
-  for (k = 0; k < tamanho; k++)
-    printf("%d\n", v[k]);
-}
-
index 8af26042738e42684f803181f568958340e2e0e3..4bf0bc315305367d7161b339e744a01617963050 100644 (file)
@@ -1,8 +1,8 @@
 #include <stdio.h>
+#include "aux.h"
 
 #define NUMELEMS 100
 
-void leVector(int a[], int tam);
 int somaVector(int a[], int tam);
 
 int main() {
@@ -15,13 +15,6 @@ int main() {
   return 0;
 }
 
-void leVector(int a[], int tam) {
-  int i;
-
-  for (i = 0; i < tam; i++)
-    scanf("%d", &a[i]);
-}
-
 int somaVector(int a[], int tam) {
   int i, soma = 0;