]> web.ist.utl.pt Git - iaed.git/commitdiff
Adding ex1 for aula03.
authorAlexandre P Francisco <aplf@ist.utl.pt>
Wed, 12 Mar 2014 13:53:51 +0000 (13:53 +0000)
committerAlexandre P Francisco <aplf@ist.utl.pt>
Wed, 12 Mar 2014 13:53:51 +0000 (13:53 +0000)
aula03/ex1.c [new file with mode: 0644]

diff --git a/aula03/ex1.c b/aula03/ex1.c
new file mode 100644 (file)
index 0000000..20879d0
--- /dev/null
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+#define NUMELEMS 5
+
+void leVector (int v[], int tamanho);
+void escreveVector(int v[], int tamanho);
+
+int main() {
+  int v[NUMELEMS];
+
+  leVector(v, NUMELEMS);
+  escreveVector(v, NUMELEMS);
+
+  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]);
+}
+