forked from malawski/ellipsoids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mean-pack-ell.cpp
41 lines (38 loc) · 989 Bytes
/
mean-pack-ell.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
#include "random.h"
#include "ellipsoid.h"
int main (int argc, char *argv[]) {
int No_parts, No_species, n = 0;
double Din, Pactual, pack = 0;
vector Box;
cout.setf(ios::fixed, ios::floatfield);
while (--argc > 1) {
ifstream pResltx (*++argv);
if (!pResltx) {
cout << "Cannot open file " << *argv << endl;
exit(1);
}
pResltx.read((char *)&No_parts, sizeof(int));
pResltx.read((char *)&Box, sizeof(vector));
pResltx.read((char *)&Pactual, sizeof(double));
pResltx.read((char *)&Din, sizeof(double));
pResltx.read((char *)&No_species, sizeof(int));
n++;
pack += Pactual;
cout << *argv << " - " << Pactual << endl;
pResltx.close();
}
cout << "--------------------------------------" << endl;
cout << pack / n << endl;
ofstream myfile;
myfile.open (*++argv);
myfile << pack / n;
myfile.close();
return 0;
}