Pagini recente » Istoria paginii runda/pcm2 | Profil Zuzi | Mihnea Andreescu | Diferente pentru flux-si-cuplaj intre reviziile 6 si 35 | Cod sursa (job #1469969)
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <vector>
using namespace std;
string firstChar, secondChar;
int main() {
ifstream in("strmatch.in");
ofstream out("strmatch.out");
in >> firstChar >> secondChar;
int lengthFirstChar = firstChar.size();
int lengthSecondChar = secondChar.size();
int noOfTotal = 0;
vector<int> poss;
for (int i=0; i<lengthSecondChar-lengthFirstChar; ++i){
if (firstChar.compare(secondChar.substr(i,lengthFirstChar)) == 0){
noOfTotal++;
poss.push_back(i);
}
if (noOfTotal >= 1000){
break;
}
}
out << noOfTotal << "\n";
for (int i=0; i<poss.size(); ++i){
out << poss.at(i) << " ";
}
return 0;
}