Hi guys, where to start!?
The problem:
1 input text file containing a name (firstname surname), followed by 12 integer numbers.
Sort the first 6 numbers, pick the highest 4 out of them, find the average.
Take the last 6 numbers, find the average of these, then add the 2 averages together.
Unknown number of names each with 12 integer values
example:
Bill Bailey
50 32 45 97 69 49 58 49 67 54 83 94
Now i am not expecting someone to spend hours working this out, i'm looking for clues as how to do it!
I managed to sort out code for the input and output files, just not the main part :P
I need to start somewhere any help much appreciated, thank youCode:#include <iostream.h> #include <fstream> using namespace std; bool getInputFilename(char fname[]) { ifstream fin; cout << "Please enter the filename for input : "; cin >> fname; fin.open(fname, ios::nocreate); if (!fin.is_open()) return false; fin.close(); return true; } bool getOutputFilename(char fname[]) { ofstream fout; cout << "Please enter the filename for output : "; cin >> fname; fout.open(fname); if (fout.fail()) return false; fout.close(); return true; } void main() { char IFname[20], OFname[20]; while (!getInputFilename(IFname)) { cout << "Invalid filename try again!\n\n"; } while (!getOutputFilename(OFname)) { cout << "Invalid filename try again!\n\n"; } }
Kel



LinkBack URL
About LinkBacks


