Cod sursa(job #1360775)
| Utilizator | Data | 25 februarie 2015 17:48:28 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 1.03 kb |
#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] << " ";
}
}
