CC=gcc
CFLAGS=-Wall -ansi -pedantic
-EXECS=ex1 ex2 ex3 ex4 ex5
+EXECS=ex1 ex2 ex3 ex4 ex5 ex6
EX1OBJ=ex1.o aux.o
EX2OBJ=ex2.o aux.o
EX3OBJ=ex3.o aux.o
EX4OBJ=ex4.o aux.o
EX5OBJ=ex5.o aux.o
+EX6OBJ=ex6.o aux.o
all: ${EXECS}
ex5: ${EX5OBJ} aux.h
gcc ${CFLAGS} -o $@ ${EX5OBJ}
+ex6: ${EX6OBJ} aux.h
+ gcc ${CFLAGS} -o $@ ${EX6OBJ}
+
clean:
rm -f *.o ${EXECS}
--- /dev/null
+#include <stdio.h>
+#include <limits.h>
+#include "aux.h"
+
+#define NUMELEMS 100
+
+void inverteVector(int v[], int tamanho);
+
+int main() {
+ int v[NUMELEMS], tam;
+
+ scanf("%d", &tam);
+ leVector(v, tam);
+ inverteVector(v, tam);
+ escreveVector(v, tam);
+
+ return 0;
+}
+
+void inverteVector(int v[], int tamanho) {
+ int i, t;
+ for (i = 0; i < (tamanho - 1)/2; i++) {
+ t = v[i];
+ v[i] = v[tamanho-i-1];
+ v[tamanho-i-1] = t;
+ }
+}
+
+