max/ min from a text file

How do I get a max or a min in my code using numbers from a text file? Any ideas or help would be great.

USING THE CODE BELOW PLEASE.
Last edited on
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
int shirts[1], posters[1], albums[1], ;
float Pshirts[1], Pposters[1], Palbums[1];
string venue[1];

ifstream fin;

fin.open("merch.txt");

ofstream fout;
fout.open("salesResults.txt");
int r=0;
while( !fin.eof() )

{
fin >> venue[0] >> shirts[0] >> Pshirts[0] >> posters[0] >> Pposters[0] >> albums[0] >> Palbums[0];
r++;
}
int overallsales;
int lowestamountofshirts;
int highestPalbums;




for( int i=0; i <= 250; i++)
{


fout << "Company that is listed last in merch.txt is " << venue[i];
fout << venue[i] << endl;
cout << "Company that is listed last in merch.txt is " << venue[i] << endl;

fout << "The number of shirts sold by " << venue[i] << " is: ";
fout << shirts[i] << endl;
cout << "The number of shirts sold by " << venue[i] << " is: ";
cout << shirts[i] << endl;

fout << "The shirts sold by " << venue[i] << " were sold for a total of: $";
fout << shirts[i]*Pshirts[i] << endl;
cout << "The shirts sold by " << venue[i] << " were sold for a total of: $";
cout << shirts[i]*Pshirts[i] << "." << endl;

}

fin.close();
fout.close();
return 0;
}
the merch.txt file's info inside of it looks like this.


Darius 5 20.00 4 15.00 3 21.00
Peter 7 21.00 4 17.00 3 20.00
Lee 10 25.00 5 18.00 6 22.00
Last edited on
Topic archived. No new replies allowed.