Pagini recente » Cod sursa (job #2385971) | Cod sursa (job #2543705) | Cod sursa (job #1632972) | Cod sursa (job #622001) | Cod sursa (job #1054007)
#include <fstream>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> vec;
typedef map<string, vec> hash;
int main(){
ifstream f("abc2.in");
ofstream g("abc2.out");
string text, word;
hash h;
int nr = 0;
f >> text >> word;
do {
int found = text.find(word);
vec v;
while (found != string::npos){
v.push_back(found);
found = text.find(word, found + word.size());
}
h[word].insert(h[word].end(), v.begin(), v.end());
f >> word;
} while (!f.eof());
for (hash::iterator i = h.begin(); i != h.end(); i++)
if (i->second.size() > 0)
nr++;
g << nr;
f.close();
g.close();
return 0;
}