Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- string findStreet(string streetList[], int streetCount);
- int locationStart (string streetList[], int streetCount,
- int start, string test);
- string currentStreet(string streetList[], int streetCount,
- int location, string test);
- bool isSubstring (string sub, string full);
- void sortStreets(string streetList[], int streetCount);
- int readStreetList(string streetList[]);
- const int MAX_STREET_COUNT = 750;
- int main()
- {
- string streetList[MAX_STREET_COUNT];
- for (int i = 0 ; i < MAX_STREET_COUNT ; i++)
- {
- streetList[i] = "";
- }
- string userInputFull = "";
- char currentChar = ' ';
- int test = readStreetList(streetList);
- int streetCount = streetList.length;
- sortStreets(streetList, streetCount);
- for (int j = 0 ; j < MAX_STREET_COUNT ; j++)
- {
- cout << streetList[j] << endl;
- }
- system ("pause");
- return 0;
- }
- string findStreet(string streetList[], int streetCount)
- {
- return 0;
- }
- int locationStart (string streetList[], int streetCount,
- int start, string test)
- {
- return 0;
- }
- string currentStreet(string streetList[], int streetCount,
- int location, string test)
- {
- return 0;
- }
- bool isSubstring (string sub, string full)
- {
- return 0;
- }
- void sortStreets(string streetList[], int streetCount)
- {
- string currentMin = "";
- int current;
- int next;
- for (current = 0; current < (streetCount-1) ; current++)
- {
- currentMin = streetList[current];
- for (next = current+1; next < streetCount; next++)
- {
- if (streetList[next] < streetList[current])
- {
- currentMin = streetList[next];
- }
- }
- swap(streetList[current], streetList[next]);
- }
- }
- int readStreetList(string streetList[])
- {
- ifstream inputFile;
- inputFile.open("streets.txt");
- if(!inputFile.is_open())
- {
- return -1;
- }
- string currentWord = "";
- int count = 0;
- while ((!inputFile.eof()) && (count <= MAX_STREET_COUNT))
- {
- inputFile >> currentWord;
- if (currentWord != "**")
- {
- streetList[count] += currentWord;
- streetList[count] += " ";
- }
- else
- {
- count++;
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement