Skip to content

Instantly share code, notes, and snippets.

@resure
Created April 20, 2011 18:58
Show Gist options
  • Save resure/932329 to your computer and use it in GitHub Desktop.
Save resure/932329 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <locale>
#include <string>
#include <set>
#include <algorithm>
#include <iterator>
#include <fstream>
#define V true
using namespace std;
inline bool check_str(string a, string b)
{
if (a.length() != b.length())
return false;
for (int i = 0; i < a.length(); i++)
if (b[i] != '*' && a[i] != b[i])
return false;
return true;
}
int main () {
setlocale(0, "russian");
string buf;
set <string> F, G, H;
ifstream in;
in.open ("F.txt");
while(!in.eof())
{
in >> buf;
F.insert(buf);
}
in.close();
in.open ("G.txt");
while(!in.eof())
{
in >> buf;
G.insert(buf);
}
in.close();
for (set<string>::iterator fi = F.begin(); fi != F.end(); fi++)
for (set<string>::iterator gi = G.begin(); gi != G.end(); gi++)
if (!check_str(*fi, *gi)) H.insert(*fi);
ofstream out;
out.open ("H.txt");
for (set<string>::iterator hi = H.begin(); hi != H.end(); hi++)
out << *hi << " ";
out.close();
if (V) cout << "Готово.\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment