aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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