Pagini recente » Cod sursa (job #2934813) | Cod sursa (job #2211939) | Cod sursa (job #105542) | Cod sursa (job #2059813) | Cod sursa (job #1591907)
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
ifstream fin ( "strmatch.in" ) ;
ofstream fout ( "strmatch.out" ) ;
int main()
{
string A , B ;
size_t n , last = string :: npos ;
vector<size_t> matches ;
int pos = 0 ;
n = B.find( A , pos ) ;
while ( n != last )
{
matches.push_back(n) ;
pos = n ;
n = B.find( A , pos ) ;
}
fout << matches.size() << '\n' ;
if ( matches.size() >= 1000 )
for ( int i = 0 ; i <= 999 ; i++ )
fout << matches[i] << ' ' ;
else
for ( vector<size_t> :: iterator it = matches.begin() ; it != matches.end() ; ++it )
fout << *it << ' ' ;
return 0;
}