wheelsmanx

CPS 171 Machine Problem 7

Dec 18th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <wctype.h>
  6. #include <vector>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13.  
  14. string filestart;
  15. string name;
  16. double data1;
  17. double dataarray[11];
  18. string names[8];
  19. int i = 0;
  20. bool firstline = true;
  21.  
  22. vector <double> divedata;
  23. vector <string> divenames;
  24.  
  25.  
  26. void parsevectors(vector <double> datainput, vector <string> nameinput) {
  27. int maincounter = 0;
  28. int secondcounter = 10;
  29. int namescounter = 0;
  30. int z = 0;
  31. int sumofdata = 0;
  32. while (maincounter != 70) {
  33. if (secondcounter == 10) {
  34. cout << nameinput.at(namescounter);
  35. namescounter++;
  36. secondcounter = 0;
  37. }
  38. dataarray[secondcounter] = datainput.at(maincounter);
  39. //cout << datainput.at(maincounter) << endl;
  40. maincounter++;
  41. secondcounter++;
  42. if (secondcounter == 10) {
  43. sort(dataarray + 2 , dataarray + 10);
  44. while (z != 10) {
  45. cout << "\t" << dataarray[z];
  46. sumofdata = sumofdata + dataarray[z];
  47. z++;
  48. }
  49. cout << " \n" << "Total Points: " << sumofdata << endl;
  50. sumofdata = 0;
  51. z = 0;
  52. }
  53. }
  54.  
  55.  
  56. }
  57.  
  58.  
  59. int main()
  60. {
  61. ifstream fileInput;
  62. fileInput.open("C:\\temp\\New Text Document.txt");
  63. while (!fileInput.eof())
  64. {
  65. if (firstline == false) {
  66. fileInput >> name;
  67. //cout << name;
  68. divenames.push_back(name);
  69. i = 0;
  70. while (i != 10) {
  71. fileInput >> data1;
  72. //cout << data1 << endl;
  73. divedata.push_back(data1);
  74. i++;
  75. }
  76. }
  77. else {
  78. // here we out skip processing the first line of the doc - and output it as the amount of strings
  79. firstline = false;
  80. int z = 0;
  81. 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;
  82. while (z != 4) {
  83. fileInput >> name;
  84. cout << name << "\t";
  85. z++;
  86. }
  87. cout << endl;
  88. }
  89.  
  90. //these are some test points to put the size of the data holders
  91. // both names and data of the divers
  92. //cout << "names :" << divenames.size() << endl;
  93. //cout << "data :" << divedata.size() << endl;
  94.  
  95. }
  96. parsevectors(divedata, divenames);
  97. system("pause");
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment