pgiovanni

Untitled

Oct 1st, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include<algorithm>
  4. #include<vector>
  5. #include<fstream>
  6. #include <cmath>
  7. #include <cstdlib>
  8.  
  9. using namespace std;
  10.  
  11.  
  12. vector<string> populate_route_28(vector<string> route_28) {
  13.     ifstream twenty8_addresses_txt;
  14.     twenty8_addresses_txt.open("C:/Users/agiov/Desktop/address 28.txt");
  15.  
  16.     string line;
  17.  
  18.     while (getline(twenty8_addresses_txt, line)) {
  19.  
  20.         route_28.push_back(line);
  21.  
  22.     }
  23.     twenty8_addresses_txt.close();
  24.  
  25.     return route_28;
  26. }
  27.  
  28. void get_packages() {
  29.     vector<int> package_indexes;
  30.     vector<string> Route_28;
  31.     string one_package_in;
  32.     bool continue_scanning = true;
  33.     cout << "Input the packges." << endl;
  34.     cout << "Input \"stop\" to stop." << endl;
  35.     Route_28 = populate_route_28(Route_28);
  36.  
  37.     do {
  38.  
  39.  
  40.  
  41.         getline(cin, one_package_in);
  42.         if (one_package_in == "stop")
  43.             continue_scanning = false;
  44.         for (unsigned int package_index = 0; package_index < Route_28.size(); ++package_index) {
  45.  
  46.             if (one_package_in == Route_28[package_index])
  47.                 package_indexes.push_back(package_index);
  48.         }
  49.  
  50.  
  51.         if (find(Route_28.begin(), Route_28.end(), one_package_in) == Route_28.end())
  52.             cout << "Package is not on this route. Check your spelling." << endl;
  53.  
  54.  
  55.     } while (continue_scanning);
  56.  
  57.     sort(package_indexes.begin(), package_indexes.end());
  58.  
  59.  
  60.     for (unsigned int i = 0; i < package_indexes.size(); ++i)
  61.  
  62.         cout << "Stop: " + to_string(++i) + Route_28[package_indexes[i]] << endl;
  63.  
  64. }
  65.  
  66.  
  67. int main(int argc, char** argv) {
  68.     vector<string> Route_28 = populate_route_28(Route_28);
  69.  
  70.     for (int i = 0; i < Route_28.size(); ++i)
  71.         cout << Route_28[i] << endl;
  72.  
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment