Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include<algorithm>
- #include<vector>
- #include<fstream>
- #include <cmath>
- #include <cstdlib>
- using namespace std;
- vector<string> populate_route_28(vector<string> route_28) {
- ifstream twenty8_addresses_txt;
- twenty8_addresses_txt.open("C:/Users/agiov/Desktop/address 28.txt");
- string line;
- while (getline(twenty8_addresses_txt, line)) {
- route_28.push_back(line);
- }
- twenty8_addresses_txt.close();
- return route_28;
- }
- void get_packages() {
- vector<int> package_indexes;
- vector<string> Route_28;
- string one_package_in;
- bool continue_scanning = true;
- cout << "Input the packges." << endl;
- cout << "Input \"stop\" to stop." << endl;
- Route_28 = populate_route_28(Route_28);
- do {
- getline(cin, one_package_in);
- if (one_package_in == "stop")
- continue_scanning = false;
- for (unsigned int package_index = 0; package_index < Route_28.size(); ++package_index) {
- if (one_package_in == Route_28[package_index])
- package_indexes.push_back(package_index);
- }
- if (find(Route_28.begin(), Route_28.end(), one_package_in) == Route_28.end())
- cout << "Package is not on this route. Check your spelling." << endl;
- } while (continue_scanning);
- sort(package_indexes.begin(), package_indexes.end());
- for (unsigned int i = 0; i < package_indexes.size(); ++i)
- cout << "Stop: " + to_string(++i) + Route_28[package_indexes[i]] << endl;
- }
- int main(int argc, char** argv) {
- vector<string> Route_28 = populate_route_28(Route_28);
- for (int i = 0; i < Route_28.size(); ++i)
- cout << Route_28[i] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment