#include <math.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int xn=0, N = 250;
double x[N],y[3*N];
string filename,outfilename;
ifstream instream;
cout<<"file"<<endl;
cin>>filename;
instream.open(filename.c_str());
cout <<"successful"<<endl;
while(xn != N)
{
instream >> x[xn];
cout << "x"<<xn << " = " << x[xn] << endl;
xn++;
}
for(xn=0;xn!=N-1;xn++)
{
y[xn]=x[xn];
y[xn+1]=0.3333*x[xn]+0.6666*x[xn+1];
y[xn+2]=0.6666*x[xn]+0.3333*x[xn+1];
}
cout<<"outfile"<<endl;
cin>>outfilename;
ofstream outfile(outfilename.c_str());
for(xn=0;xn!=N-1;xn++)
{
outfile<<0.01*xn<<" "<<y[xn]<<endl;
outfile<<0.01*(xn+0.33333)<<" "<<y[xn+1]<<endl;
outfile<<0.01*(xn+0.66666)<<" "<<y[xn+2]<<endl;
}
cout<<"done"<<endl;
return 0;
}
No comments:
Post a Comment