Pagini recente » Cod sursa (job #46710) | Cod sursa (job #1482311) | Cod sursa (job #2656345) | Cod sursa (job #727213) | Cod sursa (job #2979091)
#include <fstream>
#include <string.h>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char z[16];
int x,y;
void printz(){
for(int i = 0; i <= x-1; i++){
fout << z[i];
}
}
int main()
{
string a,b;
fin >> a >> b;
x = a.length();
y = b.length();
for(int i = 0; i <= y-x; i++){
bool ok = true;
for(int j = 0; j <= x-1; j++){
z[j] = b[i+j];
if(z[j] != a[j]){
ok = false;
// fout << z[j] << " " << a[j];
// fout << "\n";
// fout << i+j;
// fout << "\n";
// fout << "\n";
break;
}
}
if(ok){
fout << i << " " << i+x-1;
return 0;
}
}
return 0;
}