0% found this document useful (0 votes)
94 views2 pages

Sampc

This C++ program reads in data from two files, merged_bond.txt and in_coord.txt, and performs calculations on the data. It declares arrays to store integers and doubles read from the files. It opens the input and output files, then reads the data into the arrays. In a for loop, it calculates the Euclidean distance between each atom pair using their x, y, z coordinate values stored in the arrays. It outputs the atom pair index and distance to the out_dist2.txt file.

Uploaded by

laksh688
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views2 pages

Sampc

This C++ program reads in data from two files, merged_bond.txt and in_coord.txt, and performs calculations on the data. It declares arrays to store integers and doubles read from the files. It opens the input and output files, then reads the data into the arrays. In a for loop, it calculates the Euclidean distance between each atom pair using their x, y, z coordinate values stored in the arrays. It outputs the atom pair index and distance to the out_dist2.txt file.

Uploaded by

laksh688
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream>

#include<fstream>
#include<cmath>
#include <cstdlib>
#include<ctime>
using namespace std;
int main()
{
int a[11820],b[11820];
double x[11630];
double y[11630];
double z[11630];
int dup1,dup2;
double dist;
ifstream
ifstream
ofstream
ofstream

in1;
in2;
out1;
out2;

in1.open("merged_bond.txt");
in2.open("in_coord.txt");
out1.open("out_bond.txt");
out2.open("out_dist2.txt");
if(!in1)
cout<<"File opening error\n";
else
cout<<"Reading the file \n";
for(int k=1;k<=11811;k++)
{
in1>>a[k];
in1>>b[k];
out1<<a[k]<<"\t"<<b[k]<<"\n";
}
if(!in2)
cout<<"File opening error\n";
else
cout<<"Reading the file \n";
for(int i=1;i<=11619;i++)
{
in2>>x[i];
in2>>y[i];
in2>>z[i];
//out<<x[k][j][i]<<"\t"<<y[k][j][i]<<"\t"<<z[k][j]
[i]<<"\n";
}
for(int h=1;h<=11811;h++)
{
cout<<h<<"\n";
dup1=a[h];
dup2=b[h];
dist=sqrt((x[dup1]-x[dup2])*(x[dup1]-x[dup2])+(y[dup1]y[dup2])*(y[dup1]-y[dup2])+(z[dup1]-z[dup2])*(z[dup1]-z[dup2]));

}
}

out2<<h<<"\t"<<dist<<"\n";

You might also like