Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 539 Bytes

hint1-3.md

File metadata and controls

20 lines (16 loc) · 539 Bytes

It may be convenient to use arrays to store the z-values and Cartesian coordinates of the atoms:

int zval[50];
double x[50], y[50], z[50]; 

A more elegant solution is to allocate the memory dynamically for each array once you know the number of atoms:

int natom;
input >> natom;

int *zval = new int[natom];
double *x = new double[natom];
double *y = new double[natom];
double *z = new double[natom];

delete[] zval;  delete[] x;  delete[] y;  delete[] z;

Don't forget to delete[] the memory after you're finished!