aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-04-23 12:15:34 -0500
committerRossTheRoss <msattr@gmail.com>2019-04-23 12:15:34 -0500
commit207befebb4932a4cb6a6497d744ce24b10bdabec (patch)
tree969e39e8c57f144248c9c243e77a3814a75e06a9
parentFix (diff)
downloadhomework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar.gz
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar.bz2
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar.lz
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar.xz
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.tar.zst
homework-207befebb4932a4cb6a6497d744ce24b10bdabec.zip
More lab
Diffstat (limited to '')
-rw-r--r--ee1301/wk6/lab5/momentum.cpp21
-rw-r--r--ee1301/wk6/lab5/vectorArray.cpp7
2 files changed, 20 insertions, 8 deletions
diff --git a/ee1301/wk6/lab5/momentum.cpp b/ee1301/wk6/lab5/momentum.cpp
index ef7a7e7..0a19e04 100644
--- a/ee1301/wk6/lab5/momentum.cpp
+++ b/ee1301/wk6/lab5/momentum.cpp
@@ -1,6 +1,6 @@
#include <iostream>
-double* momentum (double velocity[3], double mass);
+double momentum (double velocity, double mass);
int main() {
double velocity[3];
@@ -9,14 +9,19 @@ int main() {
std::cin >> velocity[0] >> velocity[1] >> velocity [2];
std::cout << "Please enter mass [kg]: ";
std::cin >> mass;
- momentum(&velocity[3], mass);
-}
-
-double* momentum(double velocity[3], double mass) {
double* vector;
vector = new double[3];
- for (int i=0; i<2; i++) {
- vector[i]=velocity[i]*mass;
+ std::cout << "Momentum: <";
+ for (int i=0; i<=2; i++) {
+ vector[i]=momentum(velocity[i], mass);
+ std::cout << vector[i];
+ if ((i<2))
+ std::cout << ",";
}
- return vector;
+ delete[] vector;
+ std::cout << ">" << std::endl;
+}
+
+double momentum(double velocity, double mass) {
+ return velocity * mass;
} \ No newline at end of file
diff --git a/ee1301/wk6/lab5/vectorArray.cpp b/ee1301/wk6/lab5/vectorArray.cpp
new file mode 100644
index 0000000..069ef6a
--- /dev/null
+++ b/ee1301/wk6/lab5/vectorArray.cpp
@@ -0,0 +1,7 @@
+
+
+
+
+double randVec() {
+
+} \ No newline at end of file