#include #include #include #include using namespace std; bool findAbb(string building, string comp, int j, int fl); int main() { ifstream infile; int numDS; int numBuildings; string tempLine; infile.open("BUILDING.IN"); infile >> numDS; getline(infile, tempLine); for(int i = 0; i < numDS; i++) { infile >> numBuildings; getline(infile, tempLine); string array[1000]; string comp; for(int j = 0; j < numBuildings; j++) { getline(infile, array[j]); } infile >> comp; getline(infile, tempLine); cout << "Data Set " << i + 1 << ":" << endl; for(int k = 0; k < numBuildings; k++) { if(findAbb(array[k], comp, 0, 0)) cout << array[k] << endl; } } infile.close(); return 0; } bool findAbb(string building, string comp, int j, int firstLetter) { if(j == comp.length()) return true; for(int l = firstLetter; l < building.length(); l++) { if(building[l] == comp[j] || building[l] - 32 == comp[j] || building[l] == comp[j] - 32) { firstLetter = l; return findAbb(building, comp, j + 1, firstLetter + 1); } } return false; }