about summary refs log tree commit diff
path: root/cpptour/myvec.cc
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-02-28 17:25:57 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-02-28 17:25:57 +0700
commit67bb27e9f5beec4d8ca0a6c29f045d5f23d6f40f (patch)
treeb677228d71b638dd6e423b037311ef0913ba66e7 /cpptour/myvec.cc
parentee9b8fc921f48dc893808e1c9dbfbef321aa362c (diff)
downloadcp-67bb27e9f5beec4d8ca0a6c29f045d5f23d6f40f.tar.gz
[lang] Reorganize language learning archive
Diffstat (limited to 'cpptour/myvec.cc')
-rw-r--r--cpptour/myvec.cc36
1 files changed, 0 insertions, 36 deletions
diff --git a/cpptour/myvec.cc b/cpptour/myvec.cc
deleted file mode 100644
index 1314730..0000000
--- a/cpptour/myvec.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-struct Vector
-{
-  int sz;       // number of elements
-  double* elem; // pointer to elements
-};
-
-void
-vector_init (Vector& v, int s)
-{
-  v.elem = new double[s];
-  v.sz = s;
-}
-
-double
-read_and_sum (int s)
-{
-  Vector v;
-  vector_init (v, s);
-  for (int i = 0; i != s; ++i)
-    cin >> v.elem[i];
-
-  double sum = 0;
-  for (int i = 0; i != s; ++i)
-    sum += v.elem[i];
-  return sum;
-}
-
-int
-main ()
-{
-  cout << read_and_sum (5) << endl;
-}