Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. string findStreet(string streetList[], int streetCount);
  7. int locationStart (string streetList[], int streetCount,
  8. int start, string test);
  9. string currentStreet(string streetList[], int streetCount,
  10. int location, string test);
  11. bool isSubstring (string sub, string full);
  12. void sortStreets(string streetList[], int streetCount);
  13. int readStreetList(string streetList[]);
  14.  
  15. const int MAX_STREET_COUNT = 750;
  16.  
  17. int main()
  18. {
  19. string streetList[MAX_STREET_COUNT];
  20. for (int i = 0 ; i < MAX_STREET_COUNT ; i++)
  21. {
  22. streetList[i] = "";
  23. }
  24. string userInputFull = "";
  25. char currentChar = ' ';
  26.  
  27. int test = readStreetList(streetList);
  28. int streetCount = streetList.length;
  29. sortStreets(streetList, streetCount);
  30.  
  31. for (int j = 0 ; j < MAX_STREET_COUNT ; j++)
  32. {
  33. cout << streetList[j] << endl;
  34. }
  35.  
  36. system ("pause");
  37. return 0;
  38. }
  39.  
  40. string findStreet(string streetList[], int streetCount)
  41. {
  42. return 0;
  43. }
  44.  
  45. int locationStart (string streetList[], int streetCount,
  46. int start, string test)
  47. {
  48. return 0;
  49. }
  50.  
  51. string currentStreet(string streetList[], int streetCount,
  52. int location, string test)
  53. {
  54. return 0;
  55. }
  56.  
  57. bool isSubstring (string sub, string full)
  58. {
  59. return 0;
  60. }
  61.  
  62. void sortStreets(string streetList[], int streetCount)
  63. {
  64. string currentMin = "";
  65. int current;
  66. int next;
  67. for (current = 0; current < (streetCount-1) ; current++)
  68. {
  69. currentMin = streetList[current];
  70.  
  71. for (next = current+1; next < streetCount; next++)
  72. {
  73. if (streetList[next] < streetList[current])
  74. {
  75. currentMin = streetList[next];
  76. }
  77. }
  78.  
  79. swap(streetList[current], streetList[next]);
  80. }
  81.  
  82. }
  83.  
  84. int readStreetList(string streetList[])
  85. {
  86. ifstream inputFile;
  87. inputFile.open("streets.txt");
  88.  
  89. if(!inputFile.is_open())
  90. {
  91. return -1;
  92. }
  93.  
  94. string currentWord = "";
  95. int count = 0;
  96.  
  97. while ((!inputFile.eof()) && (count <= MAX_STREET_COUNT))
  98. {
  99. inputFile >> currentWord;
  100. if (currentWord != "**")
  101. {
  102. streetList[count] += currentWord;
  103. streetList[count] += " ";
  104. }
  105. else
  106. {
  107. count++;
  108. }
  109. }
  110.  
  111. return count;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement