diff options
| author | RossTheRoss <msattr@gmail.com> | 2020-02-09 08:46:52 -0600 |
|---|---|---|
| committer | RossTheRoss <msattr@gmail.com> | 2020-02-09 08:46:52 -0600 |
| commit | bd1d350c376b45e334697851e29b2f79fee0c956 (patch) | |
| tree | eb242032a64442caef7a35434400eb0818911e9a /ee1301/wk6/lab5/vectorArray.cpp | |
| parent | Do micro prelab (diff) | |
| parent | Rename file (diff) | |
| download | homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.gz homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.bz2 homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.lz homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.xz homework-bd1d350c376b45e334697851e29b2f79fee0c956.tar.zst homework-bd1d350c376b45e334697851e29b2f79fee0c956.zip | |
Merge branch 'master' of github.com:RosstheRoss/TestingFun
Diffstat (limited to 'ee1301/wk6/lab5/vectorArray.cpp')
| -rw-r--r-- | ee1301/wk6/lab5/vectorArray.cpp | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/ee1301/wk6/lab5/vectorArray.cpp b/ee1301/wk6/lab5/vectorArray.cpp deleted file mode 100644 index 92d23bd..0000000 --- a/ee1301/wk6/lab5/vectorArray.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include <iostream>
-
-double randVec();
-double momentum (double velocity);
-int main() {
- srand(time(NULL));
- double sum[3]={0,0,0};
- double* randVel; double* momArray;
- randVel = new double[1000];
- momArray = new double[1000];
- for (int i=0; i<1000; i++) {
- randVel[i]=randVec();
- momArray[i]=momentum(randVel[i]);
- int j=i%3;
- sum[j]+=momArray[i];
- }
- std::cout << '<' << sum[0]/1000.0 << ',' << sum[1]/1000.0 << ',' << sum[2]/1000.0 << '>' << std::endl;
- delete[] randVel;
- delete[] momArray;
-}
-
-
-double randVec() {
- double vector[3];
- for (int i=0; i<3; i++) {
- if (rand()%2+1==1) {
- vector[i]=rand()%100+1.0;
- } else {
- vector[i]=rand()%100*-1.0+1.0;
- }
- }
- return *vector;
-}
-
-double momentum(double velocity) {
- double mass;
- if (rand()%2+1==0) {
- mass=rand()%10+1.0;
- } else {
- mass=rand()%10*-1.0+1.0;
- }
- return mass*velocity;
-}
\ No newline at end of file |
