From 977139366cfb13dffeec9c7dbcd998b16418b43b Mon Sep 17 00:00:00 2001 From: Fabio Roberto Vitello <fabio.vitello@inaf.it> Date: Fri, 5 Jul 2019 10:27:50 +0200 Subject: [PATCH] added testMatrix Simple code to compare the output of two file --- .vscode/ipch/.DS_Store | Bin 0 -> 6148 bytes testMatrix.c | 63 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .vscode/ipch/.DS_Store create mode 100644 testMatrix.c diff --git a/.vscode/ipch/.DS_Store b/.vscode/ipch/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dc2779cd40e6f9925197eaa18911072717fc96c6 GIT binary patch literal 6148 zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwA|RR(Y=#*_DuV@sIfFSv8dPqS z8r&fOiaP-YbA}{_R0cB!<oHWuFlI1dNMW#GNJ%O$E=bDBPhwzT_?}ddlUZD1U~q$x ziJ66!jh%y&i<5_wkCP`hI3vG2xFoTpwAd-JC|*D&I5Q<RDX}O#Go>UWBsI@9C$%g! z&%ekgu_U!98l*TRKR+ia5z0<X3d>9_j~5Ve&d)1J%*;zI0x5x-5fh%7my%!ZlwX>c zQViA$l>oB?5=%0Y5{o#M9nu`Yq0Py`880AJU9D?qX=<*cU}|YltD{hDZf>BXU}9`m zTg%D8A*t>b6j$2RH*5BirOTEdISSUtz{m)p83ds;j5-F+BLsq}EVw8yCqFM8l)YdY zN9oZJ7!85Z5EzUh04?k|xCf)-M%^?T0;3@?pdkP%9~7XC8BoIt#BYG`K}-fl1_n^` z5k#}V917_NFo48BT0t~OD~JYZWncucz-EB8GB7egv@(LbAs~IAE(wSRYiD3&0BdJp zWB_Z2x6l|N+8G!j+8G$3JrqWWb_Pa>b_Pa>c9`=<>Cq4v4FPBfFhghoQ2p=9z<{g& z4^cHrj)uT!2n@>*U}SL#c5wn%%Gmt}s%t^@X#!LlRQrRfV@6OtjSvG@#Y~U^MG2@d esJaJf1<~NDn2`ZelaDq8U?DV0kA?vKLjVB(BV=#@ literal 0 HcmV?d00001 diff --git a/testMatrix.c b/testMatrix.c new file mode 100644 index 0000000..c7d96f8 --- /dev/null +++ b/testMatrix.c @@ -0,0 +1,63 @@ +#include <iostream> +#include <fstream> +#include <string> +#include <iomanip> + +using namespace std; + +int main(int argc, char *argv[]) +{ + ifstream myfile(argv[1]); + ifstream myfile1(argv[2]); + ofstream outfile("res.txt"); + + if (myfile.is_open() && myfile1.is_open()) + { + int arrSize = 0; + double arr[1001805]; // Ideally this would be a vector, but you said array + double arr1[1001805]; // Ideally this would be a vector, but you said array + + double res[1001805]; // Ideally this would be a vector, but you said array + + + while ( true) + { + double x; + myfile >> x; + if (myfile.eof()) + break; + arr[arrSize++] = x; + } + + arrSize=0; + while (true) + { + double x; + myfile1 >> x; + if (myfile1.eof()) + break; + arr1[arrSize] = x; + + res[arrSize]=arr[arrSize]-arr1[arrSize]; + outfile<<arrSize<<" "<<fixed<<setprecision(20)<< res[arrSize]<<" "<<arr[arrSize]<<" "<<arr1[arrSize]<<"\n"; + arrSize++; + } + + + + // I should have closed the file here, but as the program was ending I was lazy } + } + else + { + cout << "Unable to open file"; + } + + + outfile.close(); + myfile.close(); + myfile1.close(); + + return 0; + +} + -- GitLab