Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <wctype.h>
- #include <vector>
- #include <algorithm>
- using namespace std;
- string filestart;
- string name;
- double data1;
- double dataarray[11];
- string names[8];
- int i = 0;
- bool firstline = true;
- vector <double> divedata;
- vector <string> divenames;
- void parsevectors(vector <double> datainput, vector <string> nameinput) {
- int maincounter = 0;
- int secondcounter = 10;
- int namescounter = 0;
- int z = 0;
- int sumofdata = 0;
- while (maincounter != 70) {
- if (secondcounter == 10) {
- cout << nameinput.at(namescounter);
- namescounter++;
- secondcounter = 0;
- }
- dataarray[secondcounter] = datainput.at(maincounter);
- //cout << datainput.at(maincounter) << endl;
- maincounter++;
- secondcounter++;
- if (secondcounter == 10) {
- sort(dataarray + 2 , dataarray + 10);
- while (z != 10) {
- cout << "\t" << dataarray[z];
- sumofdata = sumofdata + dataarray[z];
- z++;
- }
- cout << " \n" << "Total Points: " << sumofdata << endl;
- sumofdata = 0;
- z = 0;
- }
- }
- }
- int main()
- {
- ifstream fileInput;
- fileInput.open("C:\\temp\\New Text Document.txt");
- while (!fileInput.eof())
- {
- if (firstline == false) {
- fileInput >> name;
- //cout << name;
- divenames.push_back(name);
- i = 0;
- while (i != 10) {
- fileInput >> data1;
- //cout << data1 << endl;
- divedata.push_back(data1);
- i++;
- }
- }
- else {
- // here we out skip processing the first line of the doc - and output it as the amount of strings
- firstline = false;
- int z = 0;
- cout << " For readability I put total points on the next line by its self because on my screen it would not line up" << endl << endl;
- while (z != 4) {
- fileInput >> name;
- cout << name << "\t";
- z++;
- }
- cout << endl;
- }
- //these are some test points to put the size of the data holders
- // both names and data of the divers
- //cout << "names :" << divenames.size() << endl;
- //cout << "data :" << divedata.size() << endl;
- }
- parsevectors(divedata, divenames);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment