//The objective is to pull out a series of numbers from an file stream
// into a list and then reverse the numbers before putting them back into
// the stream, then jump over the next profile onto the next odd profile
// e.g jump values 6,7,8,9,10 and make the next list from element ax[11]
// and so on. Then do the same for the ay co-ordinates.
#include <iostream>
#include <fstream>
#include <list>
usingnamespace std;
float array[50][2];
float ax[50];
float ay[50];
int i;
int j;
float* X0 = &ax[0]; // declare pointer
float* Y0 = &ay[0]; // declare pointer
int main()
{
ifstream in_file("C:\\bust\\fliptest.txt"); //get the file stream
if(!in_file.is_open()) {
cout<<"File not opened"<<"\n";
return 1;
}
for(i=0;i<50;i++) { //turn the stream into an array
for(j=0;j<2;j++) {
in_file >> array[i][j];
}
}
for(i=0; i<50; i++){ // pull out the X co-ordinate from the
for(j=0; j<1; j++){ // array
ax[i] = array[i][j];
}
}
for(i=0; i<50; i++){ // pull out the Y co-ordinate from the
for(j=1; j<2; j++){ // array
ay[i] = array[i][j];
}
}
std::list<float>profile_X; // set up a list
for(i=0; i<9; i++){ // loop through the file
for(i=0; i<5; i++){ // loop through to fill the list
profile_X.push_back(i)= X0; // start the list from ax[0] element
// and for 5 elements upto ax[4]
}
profile_X.reverse(); // reverse the list
for (std::list<float>::iterator it=profile_X.begin(); it!=profile_X.end(); ++it)
std::cout << ' ' << *it; // check the list has been reveresed
X0 = X0 + 5; // increament forward 5 elements to the
// start of the next list
}
return 0 ;
}
std::list<float>profile_X; // set up a list
for(i=0; i<9; i++){ // loop through the file
for(i=0; i<5; i++){ // loop through to fill the list
profile_X.push_back(X0[i]); // start the list from ax[0] element
// and for 5 elements upto ax[4]
}
std::list<float>profile_X; // set up a list profile_X
std::list<float>profile_Y; // set up a list profile_Y
for(i=0; i<5; i++){ // loop through to fill the list
profile_X.push_back( X0 [i]); // start the list from ax[0] element
// and for 5 elements upto ax[4]
}
profile_X.reverse(); // reverse the lis
for (std::list<float>::iterator it=profile_X.begin(); it!=profile_X.end(); ++it)
fout << *it<<"\n"; // check numbers reversed
for(i=0; i<5; i++){ // loop through to fill the list
profile_Y.push_back( Y0 [i]); // start the list from ay[0] element
// and for 5 elements upto ay[4]
}
profile_Y.reverse(); // reverse the list
for (std::list<float>::iterator it=profile_Y.begin(); it!=profile_Y.end(); ++it)
fout << *it<<"\n"; //// check numbers reversed
return 0 ;
}