reverse order
hello all, i'm suppose to give the output in reverse order. in the code below, is the regular order. I'm having trouble of how to reverse it
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 40 41 42
|
#include <iostream>// cerr = error output stream
#include <cstdlib> //exit
#include <string>//strings
#include <fstream>// file streams
using namespace std;
int main ()
{
double eastSt, eastEl, westSt, westEl;
string date, earlier_date, later_date ;
//get dates from user
cout << "Enter earlier date: " << endl;
cin >> earlier_date;
cout << "Enter later date: " << endl;
cin >> later_date;
// Setup data structure
double myData [400] ;
//input file stream
ifstream fin("Current_Reservoir_Levels.tsv");
if (fin.fail())
{
cerr << "File cannot be opened for reading." << endl;
exit(1);
}
string junk;
getline(fin, junk);
// loop reads the file line-by-line
while(fin >> date >> eastSt >> eastEl >> westSt >> westEl)
{
// specific dates
if ( (date >= earlier_date) && (date <= later_date ))
{
for (int i = 0; i < 1; i++)
{
myData [i] = westEl;
cout << date << " " << myData [i] << " ft" << endl;
}
}
}
fin.close();
return 0;
}
|
Topic archived. No new replies allowed.