Pagini recente » Cod sursa (job #1853693) | Cod sursa (job #2063787) | Cod sursa (job #1729523) | Cod sursa (job #2892267) | Cod sursa (job #1360775)
#include <fstream>
#include <string.h>
using namespace std;
char STR[1025];
char CMP[1025];
int megold[1025];
int eltol;
int M,N;
int q;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
void beolvas(){
in >> CMP >> STR;
M = strlen(CMP);
N = strlen(STR);
}
int main(){
beolvas();
for(int i = 0;i<N;i++){
for(int j = 0;j<M;j++){
if(STR[j] != CMP[j]){
break;
}else if(j == strlen(CMP)-1){
megold[q] = (i+eltol)/2;
q++;
}
}
for(int j = 0;j<strlen(STR);j++){
STR[j] = STR[j+1];
}
eltol++;
}
out << q << endl;
for(int i = 0;i<q;i++){
out << megold[i] << " ";
}
}