Pagini recente » Cod sursa (job #2901559) | Cod sursa (job #2903073) | Cod sursa (job #1262098) | Cod sursa (job #256320) | Cod sursa (job #1054008)
#include <fstream>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> vec;
typedef map<string, vec> ht;
int main(){
ifstream f("abc2.in");
ofstream g("abc2.out");
string text, word;
ht 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 (ht::iterator i = h.begin(); i != h.end(); i++)
if (i->second.size() > 0)
nr++;
g << nr;
f.close();
g.close();
return 0;
}